Skip to content

Commit

Permalink
Merge pull request #4495 from nebulab/spaghetticode/delete-discarded-…
Browse files Browse the repository at this point in the history
…prices

Include discarded prices in delete_prices_with_nil_amount task
  • Loading branch information
waiting-for-dev authored Aug 9, 2022
2 parents 4abe9f6 + 5846225 commit d169360
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/lib/tasks/solidus/delete_prices_with_nil_amount.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

namespace :solidus do
desc "Delete Spree::Price records which amount field is NULL"
desc "Delete Spree::Price records (including discarded) which amount field is NULL"
task delete_prices_with_nil_amount: :environment do
Spree::Price.where(amount: nil).delete_all
Spree::Price.with_discarded.where(amount: nil).delete_all
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

it 'removes all prices which amount column is NULL' do
price = create(:price)
expect(Spree::Price).to receive(:where).with(amount: nil).and_return(Spree::Price.where(id: price))
with_discarded = instance_double("Spree::Price::ActiveRecord_Relation", where: Spree::Price.where(id: price))

expect(Spree::Price).to receive(:with_discarded) { with_discarded }

task.invoke

Expand Down

0 comments on commit d169360

Please sign in to comment.