|
350 | 350 | expect(variant.default_price.attributes).to eq(price.attributes) |
351 | 351 | end |
352 | 352 |
|
353 | | - context "when the variant and the price are both soft-deleted" do |
| 353 | + context "when the variant is soft-deleted" do |
354 | 354 | it "will use a deleted price as the default price" do |
355 | 355 | variant = create(:variant, deleted_at: 1.day.ago) |
356 | | - variant.prices.each { |price| price.discard } |
357 | | - expect(variant.reload.price).to be_present |
| 356 | + expect(variant.price).to be_present |
358 | 357 | end |
359 | 358 | end |
360 | 359 |
|
361 | 360 | context "when the variant is not soft-deleted, but its price is" do |
362 | 361 | it "will not use a deleted price as the default price" do |
363 | 362 | variant = create(:variant) |
364 | | - variant.prices.each { |price| price.discard } |
| 363 | + variant.prices.each { |price| price.destroy } |
365 | 364 | expect(variant.reload.price).not_to be_present |
366 | 365 | end |
367 | 366 | end |
|
397 | 396 | end |
398 | 397 | end |
399 | 398 |
|
400 | | - context 'when default price is discarded' do |
| 399 | + context 'when default price is destroyed' do |
401 | 400 | it 'returns false' do |
402 | 401 | variant = create(:variant, price: 20) |
403 | 402 |
|
404 | | - variant.default_price.discard |
| 403 | + variant.default_price.destroy |
405 | 404 |
|
406 | | - expect(variant.has_default_price?).to be(false) |
| 405 | + expect(variant.reload.has_default_price?).to be(false) |
407 | 406 | end |
408 | 407 | end |
409 | 408 | end |
|
873 | 872 | it "should not discard default_price" do |
874 | 873 | variant.discard |
875 | 874 | variant.reload |
876 | | - expect(previous_variant_price.reload).not_to be_discarded |
| 875 | + expect(previous_variant_price.reload).to be_present |
877 | 876 | end |
878 | 877 |
|
879 | 878 | it "should keep its price if deleted" do |
|
0 commit comments