solidus_core 2.9.6 → 2.10.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/concerns/spree/user_address_book.rb +2 -2
  3. data/app/models/spree/address.rb +2 -2
  4. data/app/models/spree/adjustment.rb +9 -9
  5. data/app/models/spree/asset.rb +1 -1
  6. data/app/models/spree/base.rb +0 -2
  7. data/app/models/spree/calculator.rb +1 -1
  8. data/app/models/spree/carton.rb +3 -3
  9. data/app/models/spree/classification.rb +2 -2
  10. data/app/models/spree/credit_card.rb +2 -2
  11. data/app/models/spree/customer_return.rb +1 -1
  12. data/app/models/spree/image/paperclip_attachment.rb +1 -1
  13. data/app/models/spree/inventory_unit.rb +4 -4
  14. data/app/models/spree/line_item.rb +3 -3
  15. data/app/models/spree/line_item_action.rb +2 -2
  16. data/app/models/spree/log_entry.rb +1 -1
  17. data/app/models/spree/option_value.rb +1 -1
  18. data/app/models/spree/option_values_variant.rb +2 -2
  19. data/app/models/spree/order.rb +8 -25
  20. data/app/models/spree/order_cancellations.rb +1 -1
  21. data/app/models/spree/order_contents.rb +2 -2
  22. data/app/models/spree/order_mutex.rb +1 -1
  23. data/app/models/spree/order_promotion.rb +3 -3
  24. data/app/models/spree/order_shipping.rb +1 -1
  25. data/app/models/spree/order_taxation.rb +1 -1
  26. data/app/models/spree/payment/processing.rb +1 -1
  27. data/app/models/spree/payment.rb +4 -4
  28. data/app/models/spree/payment_capture_event.rb +1 -1
  29. data/app/models/spree/payment_method/bogus_credit_card.rb +1 -1
  30. data/app/models/spree/payment_method.rb +3 -0
  31. data/app/models/spree/payment_source.rb +1 -1
  32. data/app/models/spree/price.rb +2 -2
  33. data/app/models/spree/product/scopes.rb +217 -210
  34. data/app/models/spree/product.rb +2 -2
  35. data/app/models/spree/product_option_type.rb +2 -2
  36. data/app/models/spree/product_promotion_rule.rb +2 -2
  37. data/app/models/spree/product_property.rb +2 -2
  38. data/app/models/spree/promotion.rb +1 -1
  39. data/app/models/spree/promotion_action.rb +1 -1
  40. data/app/models/spree/promotion_code.rb +2 -2
  41. data/app/models/spree/promotion_code_batch.rb +1 -1
  42. data/app/models/spree/promotion_rule.rb +1 -1
  43. data/app/models/spree/promotion_rule_role.rb +2 -2
  44. data/app/models/spree/promotion_rule_store.rb +2 -2
  45. data/app/models/spree/promotion_rule_taxon.rb +2 -2
  46. data/app/models/spree/promotion_rule_user.rb +2 -2
  47. data/app/models/spree/refund.rb +3 -3
  48. data/app/models/spree/reimbursement/credit.rb +2 -2
  49. data/app/models/spree/reimbursement.rb +2 -2
  50. data/app/models/spree/reimbursement_tax_calculator.rb +1 -1
  51. data/app/models/spree/return_authorization.rb +3 -3
  52. data/app/models/spree/return_item.rb +10 -10
  53. data/app/models/spree/role_user.rb +2 -2
  54. data/app/models/spree/shipment.rb +3 -3
  55. data/app/models/spree/shipping_manifest.rb +3 -3
  56. data/app/models/spree/shipping_method.rb +1 -1
  57. data/app/models/spree/shipping_method_category.rb +2 -2
  58. data/app/models/spree/shipping_method_stock_location.rb +2 -2
  59. data/app/models/spree/shipping_method_zone.rb +2 -2
  60. data/app/models/spree/shipping_rate.rb +2 -2
  61. data/app/models/spree/shipping_rate_tax.rb +2 -2
  62. data/app/models/spree/state.rb +1 -1
  63. data/app/models/spree/state_change.rb +2 -2
  64. data/app/models/spree/stock_item.rb +2 -2
  65. data/app/models/spree/stock_location.rb +2 -2
  66. data/app/models/spree/stock_movement.rb +2 -2
  67. data/app/models/spree/store_credit.rb +8 -8
  68. data/app/models/spree/store_credit_event.rb +3 -3
  69. data/app/models/spree/store_payment_method.rb +2 -2
  70. data/app/models/spree/store_shipping_method.rb +2 -2
  71. data/app/models/spree/tax_rate.rb +1 -1
  72. data/app/models/spree/tax_rate_tax_category.rb +2 -2
  73. data/app/models/spree/unit_cancel.rb +5 -2
  74. data/app/models/spree/user_address.rb +2 -2
  75. data/app/models/spree/user_stock_location.rb +2 -2
  76. data/app/models/spree/variant/scopes.rb +37 -29
  77. data/app/models/spree/variant.rb +1 -1
  78. data/app/models/spree/variant_property_rule.rb +1 -1
  79. data/app/models/spree/variant_property_rule_condition.rb +2 -2
  80. data/app/models/spree/variant_property_rule_value.rb +2 -2
  81. data/app/models/spree/wallet_payment_source.rb +2 -2
  82. data/app/models/spree/zone_member.rb +2 -2
  83. data/config/initializers/inflections.rb +5 -0
  84. data/config/locales/en.yml +22 -3
  85. data/lib/generators/spree/dummy/dummy_generator.rb +2 -0
  86. data/lib/generators/spree/install/install_generator.rb +0 -3
  87. data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -21
  88. data/lib/spree/core/environment_extension.rb +0 -9
  89. data/lib/spree/core/importer/order.rb +3 -4
  90. data/lib/spree/core/importer/product.rb +2 -2
  91. data/lib/spree/core/version.rb +1 -1
  92. data/lib/spree/permission_sets/default_customer.rb +1 -1
  93. data/lib/spree/permitted_attributes.rb +6 -75
  94. data/lib/spree/testing_support/dummy_app/rake_tasks.rb +6 -2
  95. data/solidus_core.gemspec +4 -4
  96. data/spec/lib/search/base_spec.rb +5 -1
  97. data/spec/lib/search/variant_spec.rb +1 -1
  98. data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +1 -8
  99. data/spec/lib/spree/core/environment_extension_spec.rb +1 -12
  100. data/spec/lib/spree/event_spec.rb +15 -3
  101. data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +18 -4
  102. data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +1 -1
  103. data/spec/models/spree/carton_spec.rb +2 -2
  104. data/spec/models/spree/concerns/user_methods_spec.rb +3 -3
  105. data/spec/models/spree/credit_card_spec.rb +2 -2
  106. data/spec/models/spree/customer_return_spec.rb +1 -1
  107. data/spec/models/spree/order/checkout_spec.rb +1 -1
  108. data/spec/models/spree/order/outstanding_balance_integration_spec.rb +5 -5
  109. data/spec/models/spree/order/payment_spec.rb +1 -1
  110. data/spec/models/spree/order_contents_spec.rb +1 -1
  111. data/spec/models/spree/order_inventory_spec.rb +3 -3
  112. data/spec/models/spree/order_shipping_spec.rb +1 -1
  113. data/spec/models/spree/order_spec.rb +6 -6
  114. data/spec/models/spree/payment_create_spec.rb +2 -2
  115. data/spec/models/spree/payment_spec.rb +12 -12
  116. data/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +2 -2
  117. data/spec/models/spree/promotion/rules/nth_order_spec.rb +2 -2
  118. data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -1
  119. data/spec/models/spree/promotion_spec.rb +0 -4
  120. data/spec/models/spree/reimbursement_type/original_payment_spec.rb +2 -2
  121. data/spec/models/spree/return_item_spec.rb +11 -11
  122. data/spec/models/spree/shipment_spec.rb +6 -6
  123. data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +4 -4
  124. data/spec/models/spree/stock/quantifier_spec.rb +2 -2
  125. data/spec/models/spree/store_credit_spec.rb +7 -7
  126. data/spec/models/spree/tax_category_spec.rb +1 -1
  127. data/spec/models/spree/taxon_spec.rb +2 -2
  128. data/spec/models/spree/unit_cancel_spec.rb +5 -0
  129. data/spec/models/spree/user_spec.rb +3 -3
  130. metadata +32 -32
  131. data/spec/lib/spree/permitted_attributes_spec.rb +0 -41
@@ -16,7 +16,7 @@ RSpec.describe Spree::OrderInventory, type: :model do
16
16
  let(:new_quantity) { 3 }
17
17
 
18
18
  before do
19
- line_item.update_attributes!(quantity: old_quantity)
19
+ line_item.update!(quantity: old_quantity)
20
20
 
21
21
  line_item.update_column(:quantity, new_quantity)
22
22
  subject.line_item.reload
@@ -86,7 +86,7 @@ RSpec.describe Spree::OrderInventory, type: :model do
86
86
  end
87
87
 
88
88
  context "variant doesnt track inventory" do
89
- before { variant.update_attributes!(track_inventory: false) }
89
+ before { variant.update!(track_inventory: false) }
90
90
  let(:new_quantity) { 1 }
91
91
 
92
92
  it "creates on hand inventory units" do
@@ -164,7 +164,7 @@ RSpec.describe Spree::OrderInventory, type: :model do
164
164
  let(:new_quantity) { 2 }
165
165
 
166
166
  before do
167
- line_item.update_attributes!(quantity: old_quantity)
167
+ line_item.update!(quantity: old_quantity)
168
168
 
169
169
  line_item.update_column(:quantity, new_quantity)
170
170
  subject.line_item.reload
@@ -181,7 +181,7 @@ RSpec.describe Spree::OrderShipping do
181
181
  # OrderShipping#ship rather than vice versa
182
182
  context "when the tracking number is already on the shipment" do
183
183
  before do
184
- shipment.update_attributes!(tracking: 'tracking-number')
184
+ shipment.update!(tracking: 'tracking-number')
185
185
  end
186
186
 
187
187
  it "sets the tracking-number" do
@@ -678,7 +678,7 @@ RSpec.describe Spree::Order, type: :model do
678
678
  let!(:payment_method_without_store) { create(:payment_method) }
679
679
 
680
680
  context 'when the store has payment methods' do
681
- before { order.update_attributes!(store: store_with_payment_methods) }
681
+ before { order.update!(store: store_with_payment_methods) }
682
682
 
683
683
  it 'returns only the matching payment methods for that store' do
684
684
  expect(order.available_payment_methods).to match_array(
@@ -706,7 +706,7 @@ RSpec.describe Spree::Order, type: :model do
706
706
  end
707
707
 
708
708
  context 'when the store does not have payment methods' do
709
- before { order.update_attributes!(store: store_without_payment_methods) }
709
+ before { order.update!(store: store_without_payment_methods) }
710
710
 
711
711
  it 'returns all matching payment methods regardless of store' do
712
712
  expect(order.available_payment_methods).to match_array(
@@ -1443,12 +1443,12 @@ RSpec.describe Spree::Order, type: :model do
1443
1443
 
1444
1444
  describe "#total_applicable_store_credit" do
1445
1445
  context "order is in the confirm state" do
1446
- before { order.update_attributes(state: 'confirm') }
1446
+ before { order.update(state: 'confirm') }
1447
1447
  include_examples "check total store credit from payments"
1448
1448
  end
1449
1449
 
1450
1450
  context "order is completed" do
1451
- before { order.update_attributes(state: 'complete') }
1451
+ before { order.update(state: 'complete') }
1452
1452
  include_examples "check total store credit from payments"
1453
1453
  end
1454
1454
 
@@ -1462,7 +1462,7 @@ RSpec.describe Spree::Order, type: :model do
1462
1462
  context "the store credit is more than the order total" do
1463
1463
  let(:order_total) { store_credit.amount - 1 }
1464
1464
 
1465
- before { order.update_attributes(total: order_total) }
1465
+ before { order.update(total: order_total) }
1466
1466
 
1467
1467
  it "returns the order total" do
1468
1468
  expect(subject.total_applicable_store_credit).to eq order_total
@@ -1472,7 +1472,7 @@ RSpec.describe Spree::Order, type: :model do
1472
1472
  context "the store credit is less than the order total" do
1473
1473
  let(:order_total) { store_credit.amount * 10 }
1474
1474
 
1475
- before { order.update_attributes(total: order_total) }
1475
+ before { order.update(total: order_total) }
1476
1476
 
1477
1477
  it "returns the store credit amount" do
1478
1478
  expect(subject.total_applicable_store_credit).to eq store_credit.amount
@@ -122,7 +122,7 @@ module Spree
122
122
  end
123
123
 
124
124
  context 'the order has no user' do
125
- before { order.update_attributes!(user_id: nil) }
125
+ before { order.update!(user_id: nil) }
126
126
  it 'errors' do
127
127
  expect { new_payment }.to raise_error(ActiveRecord::RecordNotFound)
128
128
  end
@@ -130,7 +130,7 @@ module Spree
130
130
 
131
131
  context 'the order and the credit card have no user' do
132
132
  before do
133
- order.update_attributes!(user_id: nil)
133
+ order.update!(user_id: nil)
134
134
  credit_card.update!(user_id: nil)
135
135
  end
136
136
  it 'errors' do
@@ -134,7 +134,7 @@ RSpec.describe Spree::Payment, type: :model do
134
134
  describe "#process!" do
135
135
  context 'with autocapture' do
136
136
  before do
137
- payment.payment_method.update_attributes!(auto_capture: true)
137
+ payment.payment_method.update!(auto_capture: true)
138
138
  end
139
139
 
140
140
  it "should purchase" do
@@ -145,11 +145,11 @@ RSpec.describe Spree::Payment, type: :model do
145
145
 
146
146
  context 'without autocapture' do
147
147
  before do
148
- payment.payment_method.update_attributes!(auto_capture: false)
148
+ payment.payment_method.update!(auto_capture: false)
149
149
  end
150
150
 
151
151
  context 'when in the checkout state' do
152
- before { payment.update_attributes!(state: 'checkout') }
152
+ before { payment.update!(state: 'checkout') }
153
153
 
154
154
  it "authorizes" do
155
155
  payment.process!
@@ -158,7 +158,7 @@ RSpec.describe Spree::Payment, type: :model do
158
158
  end
159
159
 
160
160
  context 'when in the processing state' do
161
- before { payment.update_attributes!(state: 'processing') }
161
+ before { payment.update!(state: 'processing') }
162
162
 
163
163
  it "does not authorize" do
164
164
  payment.process!
@@ -167,7 +167,7 @@ RSpec.describe Spree::Payment, type: :model do
167
167
  end
168
168
 
169
169
  context 'when in the pending state' do
170
- before { payment.update_attributes!(state: 'pending') }
170
+ before { payment.update!(state: 'pending') }
171
171
 
172
172
  it "does not re-authorize" do
173
173
  expect(payment).to_not receive(:authorize!)
@@ -177,7 +177,7 @@ RSpec.describe Spree::Payment, type: :model do
177
177
  end
178
178
 
179
179
  context 'when in a failed state' do
180
- before { payment.update_attributes!(state: 'failed') }
180
+ before { payment.update!(state: 'failed') }
181
181
 
182
182
  it "raises an exception" do
183
183
  expect {
@@ -187,7 +187,7 @@ RSpec.describe Spree::Payment, type: :model do
187
187
  end
188
188
 
189
189
  context 'when in the completed state' do
190
- before { payment.update_attributes!(state: 'completed') }
190
+ before { payment.update!(state: 'completed') }
191
191
 
192
192
  it "authorizes" do
193
193
  payment.process!
@@ -253,7 +253,7 @@ RSpec.describe Spree::Payment, type: :model do
253
253
 
254
254
  context 'when the source is a credit card without an address' do
255
255
  let(:card) { create(:credit_card, address: nil) }
256
- before { order.update_attributes!(bill_address: address) }
256
+ before { order.update!(bill_address: address) }
257
257
  let(:address) { create(:address) }
258
258
 
259
259
  it 'send the order bill address' do
@@ -278,7 +278,7 @@ RSpec.describe Spree::Payment, type: :model do
278
278
 
279
279
  let(:store_credit_payment) { create(:store_credit_payment) }
280
280
  let(:store_credit_payment_method) { create(:store_credit_payment_method) }
281
- before { order.update_attributes!(bill_address: address) }
281
+ before { order.update!(bill_address: address) }
282
282
  let(:address) { create(:address) }
283
283
 
284
284
  it 'send the order bill address' do
@@ -932,7 +932,7 @@ RSpec.describe Spree::Payment, type: :model do
932
932
  end
933
933
 
934
934
  context 'the order has no user' do
935
- before { order.update_attributes!(user_id: nil) }
935
+ before { order.update!(user_id: nil) }
936
936
  it 'errors' do
937
937
  expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
938
938
  end
@@ -940,7 +940,7 @@ RSpec.describe Spree::Payment, type: :model do
940
940
 
941
941
  context 'the order and the credit card have no user' do
942
942
  before do
943
- order.update_attributes!(user_id: nil)
943
+ order.update!(user_id: nil)
944
944
  credit_card.update!(user_id: nil)
945
945
  end
946
946
  it 'errors' do
@@ -976,7 +976,7 @@ RSpec.describe Spree::Payment, type: :model do
976
976
  # Sets the payment's order to a different Ruby object entirely
977
977
  payment.order = Spree::Order.find(payment.order_id)
978
978
  email = 'foo@example.com'
979
- order.update_attributes(email: email)
979
+ order.update(email: email)
980
980
  expect(payment.gateway_options[:email]).to eq(email)
981
981
  end
982
982
  end
@@ -42,10 +42,10 @@ RSpec.describe Spree::Promotion::Rules::FirstRepeatPurchaseSince do
42
42
  let(:order_completion_date_2) { 1.day.ago }
43
43
  before do
44
44
  old_order_1 = create :completed_order_with_totals, user: user
45
- old_order_1.update_attributes(completed_at: order_completion_date_1)
45
+ old_order_1.update(completed_at: order_completion_date_1)
46
46
 
47
47
  old_order_2 = create :completed_order_with_totals, user: user
48
- old_order_2.update_attributes(completed_at: order_completion_date_2)
48
+ old_order_2.update(completed_at: order_completion_date_2)
49
49
  end
50
50
 
51
51
  context "the last completed order was greater than the preferred days ago" do
@@ -40,7 +40,7 @@ RSpec.describe Spree::Promotion::Rules::NthOrder do
40
40
  context "when the user has completed orders" do
41
41
  before do
42
42
  old_order = create :completed_order_with_totals, user: user
43
- old_order.update_attributes(completed_at: 1.day.ago)
43
+ old_order.update(completed_at: 1.day.ago)
44
44
  end
45
45
 
46
46
  context "when this order will be the 'nth' order" do
@@ -49,7 +49,7 @@ RSpec.describe Spree::Promotion::Rules::NthOrder do
49
49
 
50
50
  context "when this order is completed and is still the 'nth' order" do
51
51
  before do
52
- order.update_attributes(completed_at: Time.current)
52
+ order.update(completed_at: Time.current)
53
53
  end
54
54
 
55
55
  it { is_expected.to be true }
@@ -101,7 +101,6 @@ RSpec.describe Spree::Promotion::Rules::Taxon, type: :model do
101
101
  before do
102
102
  taxon.children << taxon2
103
103
  taxon.save!
104
- taxon.reload
105
104
  product.taxons = [taxon2, taxon3]
106
105
  rule.taxons = [taxon, taxon3]
107
106
  end
@@ -582,7 +582,6 @@ RSpec.describe Spree::Promotion, type: :model do
582
582
  end
583
583
 
584
584
  context "when the promotion's usage limit is exceeded" do
585
- let(:order) { FactoryBot.create(:completed_order_with_promotion, promotion: promotion) }
586
585
  let(:promotion) { FactoryBot.create(:promotion, :with_order_adjustment) }
587
586
 
588
587
  before do
@@ -599,7 +598,6 @@ RSpec.describe Spree::Promotion, type: :model do
599
598
  end
600
599
 
601
600
  context "when the promotion code's usage limit is exceeded" do
602
- let(:order) { FactoryBot.create(:completed_order_with_promotion, promotion: promotion) }
603
601
  let(:promotion) { create(:promotion, :with_order_adjustment, code: 'abc123', per_code_usage_limit: 1) }
604
602
  let(:promotion_code) { promotion.codes.first }
605
603
 
@@ -636,8 +634,6 @@ RSpec.describe Spree::Promotion, type: :model do
636
634
  end
637
635
 
638
636
  context "when promotable is a Spree::Order" do
639
- let(:promotable) { create :order }
640
-
641
637
  context "and it is empty" do
642
638
  it { is_expected.to be true }
643
639
  end
@@ -63,8 +63,8 @@ module Spree
63
63
  let(:refund_payment_methods) { subject.map { |refund| refund.payment.payment_method } }
64
64
 
65
65
  before do
66
- reimbursement.order.payments.first.update_attributes!(amount: 5.0)
67
- return_item.update_attributes!(amount: refund_amount)
66
+ reimbursement.order.payments.first.update!(amount: 5.0)
67
+ return_item.update!(amount: refund_amount)
68
68
  end
69
69
 
70
70
  it "includes refunds all payment type" do
@@ -26,8 +26,8 @@ RSpec.describe Spree::ReturnItem, type: :model do
26
26
  let(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
27
27
 
28
28
  before do
29
- inventory_unit.update_attributes!(state: 'shipped')
30
- return_item.update_attributes!(reception_status: 'awaiting')
29
+ inventory_unit.update!(state: 'shipped')
30
+ return_item.update!(reception_status: 'awaiting')
31
31
  allow(return_item).to receive(:eligible_for_return?).and_return(true)
32
32
  end
33
33
 
@@ -91,9 +91,9 @@ RSpec.describe Spree::ReturnItem, type: :model do
91
91
  let(:stock_item) { stock_location.stock_item(inventory_unit.variant) }
92
92
 
93
93
  before do
94
- inventory_unit.update_attributes!(state: 'shipped')
95
- return_item.update_attributes!(reception_status: 'awaiting')
96
- stock_location.update_attributes!(restock_inventory: true)
94
+ inventory_unit.update!(state: 'shipped')
95
+ return_item.update!(reception_status: 'awaiting')
96
+ stock_location.update!(restock_inventory: true)
97
97
  end
98
98
 
99
99
  it 'increases the count on hand' do
@@ -102,9 +102,9 @@ RSpec.describe Spree::ReturnItem, type: :model do
102
102
 
103
103
  context 'when variant does not track inventory' do
104
104
  before do
105
- inventory_unit.update_attributes!(state: 'shipped')
106
- inventory_unit.variant.update_attributes!(track_inventory: false)
107
- return_item.update_attributes!(reception_status: 'awaiting')
105
+ inventory_unit.update!(state: 'shipped')
106
+ inventory_unit.variant.update!(track_inventory: false)
107
+ return_item.update!(reception_status: 'awaiting')
108
108
  end
109
109
 
110
110
  it 'does not increase the count on hand' do
@@ -114,7 +114,7 @@ RSpec.describe Spree::ReturnItem, type: :model do
114
114
 
115
115
  context "when the stock location's restock_inventory is false" do
116
116
  before do
117
- stock_location.update_attributes!(restock_inventory: false)
117
+ stock_location.update!(restock_inventory: false)
118
118
  end
119
119
 
120
120
  it 'does not increase the count on hand' do
@@ -135,7 +135,7 @@ RSpec.describe Spree::ReturnItem, type: :model do
135
135
 
136
136
  Spree::ReturnItem::INTERMEDIATE_RECEPTION_STATUSES.each do |status|
137
137
  context "when the item was #{status}" do
138
- before { return_item.update_attributes!(reception_status: status) }
138
+ before { return_item.update!(reception_status: status) }
139
139
 
140
140
  it 'processes the inventory unit' do
141
141
  subject
@@ -293,7 +293,7 @@ RSpec.describe Spree::ReturnItem, type: :model do
293
293
  subject { return_item.public_send("#{transition}!") }
294
294
  context "awaiting status" do
295
295
  before do
296
- return_item.update_attributes!(reception_status: 'awaiting')
296
+ return_item.update!(reception_status: 'awaiting')
297
297
  allow(return_item).to receive(:eligible_for_return?).and_return(true)
298
298
  end
299
299
 
@@ -152,7 +152,7 @@ RSpec.describe Spree::Shipment, type: :model do
152
152
 
153
153
  describe '#total_before_tax' do
154
154
  before do
155
- shipment.update_attributes!(cost: 10)
155
+ shipment.update!(cost: 10)
156
156
  end
157
157
  let!(:admin_adjustment) { create(:adjustment, adjustable: shipment, order: shipment.order, amount: -1, source: nil) }
158
158
  let!(:promo_adjustment) { create(:adjustment, adjustable: shipment, order: shipment.order, amount: -2, source: promo_action) }
@@ -250,7 +250,7 @@ RSpec.describe Spree::Shipment, type: :model do
250
250
  end
251
251
 
252
252
  it "can't get rates without a shipping address" do
253
- shipment.order.update_attributes!(ship_address: nil)
253
+ shipment.order.update!(ship_address: nil)
254
254
  expect(shipment.refresh_rates).to eq([])
255
255
  end
256
256
 
@@ -298,7 +298,7 @@ RSpec.describe Spree::Shipment, type: :model do
298
298
  shared_examples_for "pending if backordered" do
299
299
  it "should have a state of pending if backordered" do
300
300
  # Set as ready so we can test for change
301
- shipment.update_attributes!(state: 'ready')
301
+ shipment.update!(state: 'ready')
302
302
 
303
303
  allow(shipment).to receive_messages(inventory_units: [mock_model(Spree::InventoryUnit, allow_ship?: false, canceled?: false, shipped?: false)])
304
304
  expect(shipment).to receive(:update_columns).with(state: 'pending', updated_at: kind_of(Time))
@@ -310,7 +310,7 @@ RSpec.describe Spree::Shipment, type: :model do
310
310
  before { allow(order).to receive_messages can_ship?: false }
311
311
  it "should result in a 'pending' state" do
312
312
  # Set as ready so we can test for change
313
- shipment.update_attributes!(state: 'ready')
313
+ shipment.update!(state: 'ready')
314
314
  expect(shipment).to receive(:update_columns).with(state: 'pending', updated_at: kind_of(Time))
315
315
  shipment.update_state
316
316
  end
@@ -768,8 +768,8 @@ RSpec.describe Spree::Shipment, type: :model do
768
768
  .to receive(:new).and_return(inventory_unit_finalizer)
769
769
 
770
770
  stock_item.set_count_on_hand(10)
771
- stock_item.update_attributes!(backorderable: false)
772
- inventory_unit.update_attributes!(pending: true)
771
+ stock_item.update!(backorderable: false)
772
+ inventory_unit.update!(pending: true)
773
773
  end
774
774
 
775
775
  subject { shipment.finalize! }
@@ -12,8 +12,8 @@ module Spree
12
12
 
13
13
  before do
14
14
  stock_item.set_count_on_hand(10)
15
- stock_item.update_attributes!(backorderable: false)
16
- inventory_unit.update_attributes!(pending: true)
15
+ stock_item.update!(backorderable: false)
16
+ inventory_unit.update!(pending: true)
17
17
  end
18
18
 
19
19
  subject { described_class.new([inventory_unit]).run! }
@@ -42,8 +42,8 @@ module Spree
42
42
  before do
43
43
  stock_item.set_count_on_hand(10)
44
44
  stock_item_2.set_count_on_hand(10)
45
- inventory_unit.update_attributes!(pending: true)
46
- inventory_unit_2.update_attributes!(pending: true)
45
+ inventory_unit.update!(pending: true)
46
+ inventory_unit_2.update!(pending: true)
47
47
  end
48
48
 
49
49
  subject { described_class.new([inventory_unit, inventory_unit_2]).run! }
@@ -49,7 +49,7 @@ module Spree
49
49
  end
50
50
 
51
51
  context 'when stock item prevents backordering' do
52
- before { stock_item.update_attributes(backorderable: false) }
52
+ before { stock_item.update(backorderable: false) }
53
53
 
54
54
  specify { expect(subject.backorderable?).to be false }
55
55
 
@@ -81,7 +81,7 @@ module Spree
81
81
  end
82
82
 
83
83
  context 'when all stock items prevent backordering' do
84
- before { stock_item.update_attributes(backorderable: false) }
84
+ before { stock_item.update(backorderable: false) }
85
85
 
86
86
  specify { expect(subject.backorderable?).to be false }
87
87
 
@@ -120,7 +120,7 @@ RSpec.describe Spree::StoreCredit do
120
120
  let!(:store_credit) { create(:store_credit) }
121
121
  let!(:test_category) { create(:store_credit_category, name: "Testing") }
122
122
 
123
- subject { store_credit.update_attributes(category: test_category) }
123
+ subject { store_credit.update(category: test_category) }
124
124
 
125
125
  it "returns false" do
126
126
  expect(subject).to eq false
@@ -170,7 +170,7 @@ RSpec.describe Spree::StoreCredit do
170
170
  context "the authorized amount is defined" do
171
171
  let(:authorized_amount) { 15.00 }
172
172
 
173
- before { store_credit.update_attributes(amount_authorized: authorized_amount) }
173
+ before { store_credit.update(amount_authorized: authorized_amount) }
174
174
 
175
175
  it "subtracts the authorized amount from the credited amount" do
176
176
  expect(store_credit.amount_remaining).to eq(store_credit.amount - authorized_amount)
@@ -181,7 +181,7 @@ RSpec.describe Spree::StoreCredit do
181
181
  context "the amount_used is defined" do
182
182
  let(:amount_used) { 10.0 }
183
183
 
184
- before { store_credit.update_attributes(amount_used: amount_used) }
184
+ before { store_credit.update(amount_used: amount_used) }
185
185
 
186
186
  context "the authorized amount is not defined" do
187
187
  it "subtracts the amount used from the credited amount" do
@@ -192,7 +192,7 @@ RSpec.describe Spree::StoreCredit do
192
192
  context "the authorized amount is defined" do
193
193
  let(:authorized_amount) { 15.00 }
194
194
 
195
- before { store_credit.update_attributes(amount_authorized: authorized_amount) }
195
+ before { store_credit.update(amount_authorized: authorized_amount) }
196
196
 
197
197
  it "subtracts the amount used and the authorized amount from the credited amount" do
198
198
  expect(store_credit.amount_remaining).to eq(store_credit.amount - amount_used - authorized_amount)
@@ -208,7 +208,7 @@ RSpec.describe Spree::StoreCredit do
208
208
  let(:originator) { nil }
209
209
 
210
210
  context "amount has not been authorized yet" do
211
- before { store_credit.update_attributes(amount_authorized: authorization_amount) }
211
+ before { store_credit.update(amount_authorized: authorization_amount) }
212
212
 
213
213
  it "returns true" do
214
214
  expect(store_credit.authorize(store_credit.amount - authorization_amount, store_credit.currency)).to be_truthy
@@ -234,7 +234,7 @@ RSpec.describe Spree::StoreCredit do
234
234
  context "authorization has already happened" do
235
235
  let!(:auth_event) { create(:store_credit_auth_event, store_credit: store_credit) }
236
236
 
237
- before { store_credit.update_attributes(amount_authorized: store_credit.amount) }
237
+ before { store_credit.update(amount_authorized: store_credit.amount) }
238
238
 
239
239
  it "returns true" do
240
240
  expect(store_credit.authorize(store_credit.amount, store_credit.currency, action_authorization_code: auth_event.authorization_code)).to be true
@@ -816,7 +816,7 @@ RSpec.describe Spree::StoreCredit do
816
816
  context "amount is valid" do
817
817
  let(:amount) { 10.0 }
818
818
 
819
- before { store_credit.update_attributes!(amount: 30.0) }
819
+ before { store_credit.update!(amount: 30.0) }
820
820
 
821
821
  it "returns true" do
822
822
  expect(subject).to eq true
@@ -12,7 +12,7 @@ RSpec.describe Spree::TaxCategory, type: :model do
12
12
  end
13
13
 
14
14
  it "should undefault the previous default tax category" do
15
- new_tax_category.update_attributes({ is_default: true })
15
+ new_tax_category.update({ is_default: true })
16
16
  expect(new_tax_category.is_default).to be true
17
17
 
18
18
  tax_category.reload
@@ -29,7 +29,7 @@ RSpec.describe Spree::Taxon, type: :model do
29
29
  context "updating a taxon permalink" do
30
30
  it 'parameterizes permalink correctly' do
31
31
  taxon.save!
32
- taxon.update_attributes(permalink: 'spécial&charactèrs')
32
+ taxon.update(permalink: 'spécial&charactèrs')
33
33
  expect(taxon.permalink).to eql "special-characters"
34
34
  end
35
35
  end
@@ -51,7 +51,7 @@ RSpec.describe Spree::Taxon, type: :model do
51
51
 
52
52
  it 'parameterizes permalink correctly' do
53
53
  taxon.save!
54
- taxon.update_attributes(permalink_part: 'spécial&charactèrs')
54
+ taxon.update(permalink_part: 'spécial&charactèrs')
55
55
  expect(taxon.reload.permalink).to eql "brands/special-characters"
56
56
  end
57
57
 
@@ -48,6 +48,11 @@ RSpec.describe Spree::UnitCancel do
48
48
  it "divides the line item total by the uncanceled units size" do
49
49
  expect(subject).to eq(-10.0)
50
50
  end
51
+
52
+ it "raises an error if dividing by 0" do
53
+ inventory_unit.cancel!
54
+ expect { subject }.to raise_error ZeroDivisionError, "Line Item does not have any inventory units available to cancel"
55
+ end
51
56
  end
52
57
 
53
58
  context "it is called with a line item that doesnt belong to the inventory unit" do
@@ -200,12 +200,12 @@ RSpec.describe Spree.user_class, type: :model do
200
200
  context "part of the store credit has been used" do
201
201
  let(:amount_used) { 35.00 }
202
202
 
203
- before { store_credit.update_attributes(amount_used: amount_used) }
203
+ before { store_credit.update(amount_used: amount_used) }
204
204
 
205
205
  context "part of the store credit has been authorized" do
206
206
  let(:authorized_amount) { 10 }
207
207
 
208
- before { additional_store_credit.update_attributes(amount_authorized: authorized_amount) }
208
+ before { additional_store_credit.update(amount_authorized: authorized_amount) }
209
209
 
210
210
  it "returns sum of amounts minus used amount and authorized amount" do
211
211
  expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount - amount_used - authorized_amount)
@@ -223,7 +223,7 @@ RSpec.describe Spree.user_class, type: :model do
223
223
  context "part of the store credit has been authorized" do
224
224
  let(:authorized_amount) { 10 }
225
225
 
226
- before { additional_store_credit.update_attributes(amount_authorized: authorized_amount) }
226
+ before { additional_store_credit.update(amount_authorized: authorized_amount) }
227
227
 
228
228
  it "returns sum of amounts minus authorized amount" do
229
229
  expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount - authorized_amount)