spree_core 3.2.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +1 -1
- metadata +3 -206
- data/spec/fixtures/microdata.html +0 -22
- data/spec/fixtures/microdata_itemref.html +0 -15
- data/spec/fixtures/microdata_no_itemscope.html +0 -20
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/helpers/base_helper_spec.rb +0 -200
- data/spec/helpers/products_helper_spec.rb +0 -289
- data/spec/lib/calculated_adjustments_spec.rb +0 -7
- data/spec/lib/i18n_spec.rb +0 -123
- data/spec/lib/search/base_spec.rb +0 -86
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +0 -103
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +0 -110
- data/spec/lib/spree/core/controller_helpers/search_spec.rb +0 -17
- data/spec/lib/spree/core/controller_helpers/store_spec.rb +0 -72
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +0 -39
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -22
- data/spec/lib/spree/core/importer/order_spec.rb +0 -605
- data/spec/lib/spree/core/number_generator_spec.rb +0 -175
- data/spec/lib/spree/core/token_generator_spec.rb +0 -24
- data/spec/lib/spree/core/validators/email_spec.rb +0 -53
- data/spec/lib/spree/core_spec.rb +0 -23
- data/spec/lib/spree/localized_number_spec.rb +0 -48
- data/spec/lib/spree/migrations_spec.rb +0 -36
- data/spec/lib/spree/money_spec.rb +0 -122
- data/spec/lib/tasks/exchanges_spec.rb +0 -136
- data/spec/mailers/order_mailer_spec.rb +0 -122
- data/spec/mailers/reimbursement_mailer_spec.rb +0 -47
- data/spec/mailers/shipment_mailer_spec.rb +0 -81
- data/spec/mailers/test_mailer_spec.rb +0 -38
- data/spec/models/option_type_prototype_spec.rb +0 -9
- data/spec/models/spree/ability_spec.rb +0 -251
- data/spec/models/spree/address_spec.rb +0 -402
- data/spec/models/spree/adjustable/adjuster/base_spec.rb +0 -10
- data/spec/models/spree/adjustable/adjuster/promotion_spec.rb +0 -211
- data/spec/models/spree/adjustable/adjuster/tax_spec.rb +0 -86
- data/spec/models/spree/adjustable/adjustments_updater_spec.rb +0 -26
- data/spec/models/spree/adjustment_spec.rb +0 -189
- data/spec/models/spree/app_configuration_spec.rb +0 -26
- data/spec/models/spree/asset_spec.rb +0 -28
- data/spec/models/spree/calculator/default_tax_spec.rb +0 -152
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +0 -25
- data/spec/models/spree/calculator/flat_rate_spec.rb +0 -47
- data/spec/models/spree/calculator/flexi_rate_spec.rb +0 -41
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +0 -15
- data/spec/models/spree/calculator/price_sack_spec.rb +0 -30
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +0 -47
- data/spec/models/spree/calculator/shipping.rb +0 -8
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +0 -23
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +0 -13
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +0 -52
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +0 -20
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +0 -29
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +0 -40
- data/spec/models/spree/calculator/tiered_percent_spec.rb +0 -51
- data/spec/models/spree/calculator_spec.rb +0 -69
- data/spec/models/spree/classification_spec.rb +0 -93
- data/spec/models/spree/concerns/display_money_spec.rb +0 -43
- data/spec/models/spree/concerns/user_methods_spec.rb +0 -82
- data/spec/models/spree/concerns/vat_price_calculation_spec.rb +0 -66
- data/spec/models/spree/country_spec.rb +0 -55
- data/spec/models/spree/credit_card_spec.rb +0 -328
- data/spec/models/spree/customer_return_spec.rb +0 -240
- data/spec/models/spree/exchange_spec.rb +0 -75
- data/spec/models/spree/gateway/bogus_simple.rb +0 -20
- data/spec/models/spree/gateway/bogus_spec.rb +0 -13
- data/spec/models/spree/gateway_spec.rb +0 -61
- data/spec/models/spree/image_spec.rb +0 -8
- data/spec/models/spree/inventory_unit_spec.rb +0 -256
- data/spec/models/spree/line_item_spec.rb +0 -346
- data/spec/models/spree/option_type_spec.rb +0 -14
- data/spec/models/spree/option_value_spec.rb +0 -18
- data/spec/models/spree/order/address_spec.rb +0 -50
- data/spec/models/spree/order/adjustments_spec.rb +0 -29
- data/spec/models/spree/order/callbacks_spec.rb +0 -42
- data/spec/models/spree/order/checkout_spec.rb +0 -770
- data/spec/models/spree/order/currency_updater_spec.rb +0 -32
- data/spec/models/spree/order/finalizing_spec.rb +0 -114
- data/spec/models/spree/order/helpers_spec.rb +0 -5
- data/spec/models/spree/order/payment_spec.rb +0 -214
- data/spec/models/spree/order/risk_assessment_spec.rb +0 -84
- data/spec/models/spree/order/shipments_spec.rb +0 -43
- data/spec/models/spree/order/state_machine_spec.rb +0 -212
- data/spec/models/spree/order/store_credit_spec.rb +0 -426
- data/spec/models/spree/order/tax_spec.rb +0 -84
- data/spec/models/spree/order/totals_spec.rb +0 -24
- data/spec/models/spree/order/updating_spec.rb +0 -18
- data/spec/models/spree/order/validations_spec.rb +0 -15
- data/spec/models/spree/order_contents_spec.rb +0 -297
- data/spec/models/spree/order_inventory_spec.rb +0 -239
- data/spec/models/spree/order_merger_spec.rb +0 -135
- data/spec/models/spree/order_spec.rb +0 -1046
- data/spec/models/spree/order_updater_spec.rb +0 -305
- data/spec/models/spree/payment/gateway_options_spec.rb +0 -127
- data/spec/models/spree/payment/store_credit_spec.rb +0 -60
- data/spec/models/spree/payment_method/store_credit_spec.rb +0 -291
- data/spec/models/spree/payment_method_spec.rb +0 -103
- data/spec/models/spree/payment_spec.rb +0 -919
- data/spec/models/spree/preference_spec.rb +0 -80
- data/spec/models/spree/preferences/configuration_spec.rb +0 -30
- data/spec/models/spree/preferences/preferable_spec.rb +0 -344
- data/spec/models/spree/preferences/scoped_store_spec.rb +0 -58
- data/spec/models/spree/preferences/store_spec.rb +0 -46
- data/spec/models/spree/price_spec.rb +0 -128
- data/spec/models/spree/product/scopes_spec.rb +0 -183
- data/spec/models/spree/product_duplicator_spec.rb +0 -103
- data/spec/models/spree/product_filter_spec.rb +0 -26
- data/spec/models/spree/product_option_type_spec.rb +0 -9
- data/spec/models/spree/product_promotion_rule_spec.rb +0 -9
- data/spec/models/spree/product_property_spec.rb +0 -26
- data/spec/models/spree/product_spec.rb +0 -629
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +0 -113
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +0 -148
- data/spec/models/spree/promotion/actions/create_line_items_spec.rb +0 -86
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +0 -36
- data/spec/models/spree/promotion/rules/country_spec.rb +0 -36
- data/spec/models/spree/promotion/rules/first_order_spec.rb +0 -75
- data/spec/models/spree/promotion/rules/item_total_spec.rb +0 -282
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +0 -42
- data/spec/models/spree/promotion/rules/option_value_spec.rb +0 -90
- data/spec/models/spree/promotion/rules/product_spec.rb +0 -143
- data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -102
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +0 -27
- data/spec/models/spree/promotion/rules/user_spec.rb +0 -45
- data/spec/models/spree/promotion_action_spec.rb +0 -10
- data/spec/models/spree/promotion_category_spec.rb +0 -17
- data/spec/models/spree/promotion_handler/cart_spec.rb +0 -102
- data/spec/models/spree/promotion_handler/coupon_spec.rb +0 -323
- data/spec/models/spree/promotion_handler/free_shipping_spec.rb +0 -48
- data/spec/models/spree/promotion_handler/page_spec.rb +0 -44
- data/spec/models/spree/promotion_rule_spec.rb +0 -29
- data/spec/models/spree/promotion_rule_taxon_spec.rb +0 -9
- data/spec/models/spree/promotion_rule_user_spec.rb +0 -9
- data/spec/models/spree/promotion_spec.rb +0 -679
- data/spec/models/spree/property_prototype_spec.rb +0 -9
- data/spec/models/spree/property_spec.rb +0 -5
- data/spec/models/spree/prototype_spec.rb +0 -5
- data/spec/models/spree/prototype_taxon_spec.rb +0 -9
- data/spec/models/spree/refund_reason_spec.rb +0 -20
- data/spec/models/spree/refund_spec.rb +0 -195
- data/spec/models/spree/reimbursement/credit_spec.rb +0 -36
- data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +0 -140
- data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +0 -83
- data/spec/models/spree/reimbursement_performer_spec.rb +0 -30
- data/spec/models/spree/reimbursement_spec.rb +0 -188
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +0 -63
- data/spec/models/spree/reimbursement_type/credit_spec.rb +0 -53
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +0 -46
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +0 -55
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +0 -101
- data/spec/models/spree/return_authorization_reason_spec.rb +0 -7
- data/spec/models/spree/return_authorization_spec.rb +0 -230
- data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +0 -77
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +0 -58
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +0 -61
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +0 -32
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +0 -29
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +0 -35
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +0 -65
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +0 -43
- data/spec/models/spree/return_item_spec.rb +0 -731
- data/spec/models/spree/returns_calculator_spec.rb +0 -14
- data/spec/models/spree/role_spec.rb +0 -7
- data/spec/models/spree/shipment_spec.rb +0 -742
- data/spec/models/spree/shipping_calculator_spec.rb +0 -45
- data/spec/models/spree/shipping_category_spec.rb +0 -19
- data/spec/models/spree/shipping_method_spec.rb +0 -95
- data/spec/models/spree/shipping_rate_spec.rb +0 -140
- data/spec/models/spree/state_spec.rb +0 -29
- data/spec/models/spree/stock/availability_validator_spec.rb +0 -36
- data/spec/models/spree/stock/content_item_spec.rb +0 -31
- data/spec/models/spree/stock/coordinator_spec.rb +0 -61
- data/spec/models/spree/stock/differentiator_spec.rb +0 -39
- data/spec/models/spree/stock/estimator_spec.rb +0 -202
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +0 -38
- data/spec/models/spree/stock/package_spec.rb +0 -182
- data/spec/models/spree/stock/packer_spec.rb +0 -70
- data/spec/models/spree/stock/prioritizer_spec.rb +0 -125
- data/spec/models/spree/stock/quantifier_spec.rb +0 -126
- data/spec/models/spree/stock/splitter/backordered_spec.rb +0 -29
- data/spec/models/spree/stock/splitter/base_spec.rb +0 -21
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +0 -47
- data/spec/models/spree/stock/splitter/weight_spec.rb +0 -32
- data/spec/models/spree/stock_item_spec.rb +0 -432
- data/spec/models/spree/stock_location_spec.rb +0 -243
- data/spec/models/spree/stock_movement_spec.rb +0 -120
- data/spec/models/spree/stock_transfer_spec.rb +0 -50
- data/spec/models/spree/store_credit_event_spec.rb +0 -101
- data/spec/models/spree/store_credit_spec.rb +0 -786
- data/spec/models/spree/store_spec.rb +0 -78
- data/spec/models/spree/tax_category_spec.rb +0 -32
- data/spec/models/spree/tax_rate_spec.rb +0 -561
- data/spec/models/spree/taxon_spec.rb +0 -85
- data/spec/models/spree/taxonomy_spec.rb +0 -18
- data/spec/models/spree/tracker_spec.rb +0 -21
- data/spec/models/spree/user_spec.rb +0 -203
- data/spec/models/spree/variant_spec.rb +0 -818
- data/spec/models/spree/zone_member_spec.rb +0 -38
- data/spec/models/spree/zone_spec.rb +0 -472
- data/spec/spec_helper.rb +0 -79
- data/spec/support/big_decimal.rb +0 -5
- data/spec/support/concerns/adjustment_source.rb +0 -23
- data/spec/support/concerns/default_price.rb +0 -37
- data/spec/support/rake.rb +0 -13
- data/spec/support/test_gateway.rb +0 -2
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
describe Spree::Order, type: :model do
|
|
5
|
-
let(:order) { stub_model(Spree::Order) }
|
|
6
|
-
|
|
7
|
-
context "#tax_zone" do
|
|
8
|
-
let(:bill_address) { create :address }
|
|
9
|
-
let(:ship_address) { create :address }
|
|
10
|
-
let(:order) { Spree::Order.create(ship_address: ship_address, bill_address: bill_address) }
|
|
11
|
-
let(:zone) { create :zone }
|
|
12
|
-
|
|
13
|
-
context "when no zones exist" do
|
|
14
|
-
it "should return nil" do
|
|
15
|
-
expect(order.tax_zone).to be_nil
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when tax_using_ship_address: true" do
|
|
20
|
-
before { Spree::Config.set(tax_using_ship_address: true) }
|
|
21
|
-
|
|
22
|
-
it "should calculate using ship_address" do
|
|
23
|
-
expect(Spree::Zone).to receive(:match).at_least(:once).with(ship_address)
|
|
24
|
-
expect(Spree::Zone).not_to receive(:match).with(bill_address)
|
|
25
|
-
order.tax_zone
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
context "when tax_using_ship_address: false" do
|
|
30
|
-
before { Spree::Config.set(tax_using_ship_address: false) }
|
|
31
|
-
|
|
32
|
-
it "should calculate using bill_address" do
|
|
33
|
-
expect(Spree::Zone).to receive(:match).at_least(:once).with(bill_address)
|
|
34
|
-
expect(Spree::Zone).not_to receive(:match).with(ship_address)
|
|
35
|
-
order.tax_zone
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context "when there is a default tax zone" do
|
|
40
|
-
before do
|
|
41
|
-
@default_zone = create(:zone, name: "foo_zone")
|
|
42
|
-
allow(Spree::Zone).to receive_messages default_tax: @default_zone
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when there is a matching zone" do
|
|
46
|
-
before { allow(Spree::Zone).to receive_messages(match: zone) }
|
|
47
|
-
|
|
48
|
-
it "should return the matching zone" do
|
|
49
|
-
expect(order.tax_zone).to eq(zone)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "when there is no matching zone" do
|
|
54
|
-
before { allow(Spree::Zone).to receive_messages(match: nil) }
|
|
55
|
-
|
|
56
|
-
it "should return the default tax zone" do
|
|
57
|
-
expect(order.tax_zone).to eq(@default_zone)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context "when no default tax zone" do
|
|
63
|
-
before { allow(Spree::Zone).to receive_messages default_tax: nil }
|
|
64
|
-
|
|
65
|
-
context "when there is a matching zone" do
|
|
66
|
-
before { allow(Spree::Zone).to receive_messages(match: zone) }
|
|
67
|
-
|
|
68
|
-
it "should return the matching zone" do
|
|
69
|
-
expect(order.tax_zone).to eq(zone)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context "when there is no matching zone" do
|
|
74
|
-
before { allow(Spree::Zone).to receive_messages(match: nil) }
|
|
75
|
-
|
|
76
|
-
it "should return nil" do
|
|
77
|
-
expect(order.tax_zone).to be_nil
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
describe Order, type: :model do
|
|
5
|
-
let(:order) { Order.create }
|
|
6
|
-
let(:shirt) { create(:variant) }
|
|
7
|
-
|
|
8
|
-
context "adds item to cart and activates promo" do
|
|
9
|
-
let(:promotion) { Promotion.create name: 'Huhu' }
|
|
10
|
-
let(:calculator) { Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) }
|
|
11
|
-
let!(:action) { Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) }
|
|
12
|
-
|
|
13
|
-
before { order.contents.add(shirt, 1) }
|
|
14
|
-
|
|
15
|
-
context "item quantity changes" do
|
|
16
|
-
it "recalculates order adjustments" do
|
|
17
|
-
expect {
|
|
18
|
-
order.contents.add(shirt, 3)
|
|
19
|
-
}.to change { order.adjustments.eligible.pluck(:amount) }
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::Order, type: :model do
|
|
4
|
-
let(:order) { create(:order) }
|
|
5
|
-
|
|
6
|
-
context "#update_with_updater!" do
|
|
7
|
-
let(:line_items) { [mock_model(Spree::LineItem, amount: 5) ]}
|
|
8
|
-
|
|
9
|
-
context "when there are update hooks" do
|
|
10
|
-
before { Spree::Order.register_update_hook :foo }
|
|
11
|
-
after { Spree::Order.update_hooks.clear }
|
|
12
|
-
it "should call each of the update hooks" do
|
|
13
|
-
expect(order).to receive :foo
|
|
14
|
-
order.update_with_updater!
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
describe Spree::Order, type: :model do
|
|
5
|
-
context "validations" do
|
|
6
|
-
# Regression test for #2214
|
|
7
|
-
it "does not return two error messages when email is blank" do
|
|
8
|
-
order = Spree::Order.new
|
|
9
|
-
allow(order).to receive_messages(require_email: true)
|
|
10
|
-
order.valid?
|
|
11
|
-
expect(order.errors[:email]).to eq(["can't be blank"])
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::OrderContents, type: :model do
|
|
4
|
-
let(:order) { Spree::Order.create }
|
|
5
|
-
let(:variant) { create(:variant) }
|
|
6
|
-
|
|
7
|
-
subject { described_class.new(order) }
|
|
8
|
-
|
|
9
|
-
context "#add" do
|
|
10
|
-
context 'given quantity is not explicitly provided' do
|
|
11
|
-
it 'should add one line item' do
|
|
12
|
-
line_item = subject.add(variant)
|
|
13
|
-
expect(line_item.quantity).to eq(1)
|
|
14
|
-
expect(order.line_items.size).to eq(1)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'given a shipment' do
|
|
19
|
-
it "ensure shipment calls update_amounts instead of order calling ensure_updated_shipments" do
|
|
20
|
-
shipment = create(:shipment)
|
|
21
|
-
expect(subject.order).to_not receive(:ensure_updated_shipments)
|
|
22
|
-
expect(shipment).to receive(:update_amounts)
|
|
23
|
-
subject.add(variant, 1, shipment: shipment)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'not given a shipment' do
|
|
28
|
-
it "ensures updated shipments" do
|
|
29
|
-
expect(subject.order).to receive(:ensure_updated_shipments)
|
|
30
|
-
subject.add(variant)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'should add line item if one does not exist' do
|
|
35
|
-
line_item = subject.add(variant, 1)
|
|
36
|
-
expect(line_item.quantity).to eq(1)
|
|
37
|
-
expect(order.line_items.size).to eq(1)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should update line item if one exists' do
|
|
41
|
-
subject.add(variant, 1)
|
|
42
|
-
line_item = subject.add(variant, 1)
|
|
43
|
-
expect(line_item.quantity).to eq(2)
|
|
44
|
-
expect(order.line_items.size).to eq(1)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should update order totals" do
|
|
48
|
-
expect(order.item_total.to_f).to eq(0.00)
|
|
49
|
-
expect(order.total.to_f).to eq(0.00)
|
|
50
|
-
|
|
51
|
-
subject.add(variant, 1)
|
|
52
|
-
|
|
53
|
-
expect(order.item_total.to_f).to eq(19.99)
|
|
54
|
-
expect(order.total.to_f).to eq(19.99)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "running promotions" do
|
|
58
|
-
let(:promotion) { create(:promotion) }
|
|
59
|
-
let(:calculator) { Spree::Calculator::FlatRate.new(preferred_amount: 10) }
|
|
60
|
-
|
|
61
|
-
shared_context "discount changes order total" do
|
|
62
|
-
before { subject.add(variant, 1) }
|
|
63
|
-
it { expect(subject.order.total).not_to eq variant.price }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "one active order promotion" do
|
|
67
|
-
let!(:action) { Spree::Promotion::Actions::CreateAdjustment.create(promotion: promotion, calculator: calculator) }
|
|
68
|
-
|
|
69
|
-
it "creates valid discount on order" do
|
|
70
|
-
subject.add(variant, 1)
|
|
71
|
-
expect(subject.order.adjustments.to_a.sum(&:amount)).not_to eq 0
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
include_context "discount changes order total"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context "one active line item promotion" do
|
|
78
|
-
let!(:action) { Spree::Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) }
|
|
79
|
-
|
|
80
|
-
it "creates valid discount on order" do
|
|
81
|
-
subject.add(variant, 1)
|
|
82
|
-
expect(subject.order.line_item_adjustments.to_a.sum(&:amount)).not_to eq 0
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
include_context "discount changes order total"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
context "VAT for variant with percent promotion" do
|
|
89
|
-
let!(:category) { Spree::TaxCategory.create name: "Taxable Foo" }
|
|
90
|
-
let!(:rate) do
|
|
91
|
-
Spree::TaxRate.create(
|
|
92
|
-
amount: 0.25,
|
|
93
|
-
included_in_price: true,
|
|
94
|
-
calculator: Spree::Calculator::DefaultTax.create,
|
|
95
|
-
tax_category: category,
|
|
96
|
-
zone: create(:zone_with_country, default_tax: true)
|
|
97
|
-
)
|
|
98
|
-
end
|
|
99
|
-
let(:variant) { create(:variant, price: 1000) }
|
|
100
|
-
let(:calculator) { Spree::Calculator::PercentOnLineItem.new(preferred_percent: 50) }
|
|
101
|
-
let!(:action) { Spree::Promotion::Actions::CreateItemAdjustments.create(promotion: promotion, calculator: calculator) }
|
|
102
|
-
|
|
103
|
-
it "should update included_tax_total" do
|
|
104
|
-
expect(order.included_tax_total.to_f).to eq(0.00)
|
|
105
|
-
subject.add(variant, 1)
|
|
106
|
-
expect(order.included_tax_total.to_f).to eq(100)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "should update included_tax_total after adding two line items" do
|
|
110
|
-
subject.add(variant, 1)
|
|
111
|
-
expect(order.included_tax_total.to_f).to eq(100)
|
|
112
|
-
subject.add(variant, 1)
|
|
113
|
-
expect(order.included_tax_total.to_f).to eq(200)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
context "#remove" do
|
|
120
|
-
context "given an invalid variant" do
|
|
121
|
-
it "raises an exception" do
|
|
122
|
-
expect {
|
|
123
|
-
subject.remove(variant, 1)
|
|
124
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context 'given quantity is not explicitly provided' do
|
|
129
|
-
it 'should remove one line item' do
|
|
130
|
-
line_item = subject.add(variant, 3)
|
|
131
|
-
subject.remove(variant)
|
|
132
|
-
|
|
133
|
-
expect(line_item.quantity).to eq(2)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context 'given a shipment' do
|
|
138
|
-
it "ensure shipment calls update_amounts instead of order calling ensure_updated_shipments" do
|
|
139
|
-
line_item = subject.add(variant, 1)
|
|
140
|
-
shipment = create(:shipment)
|
|
141
|
-
expect(subject.order).to_not receive(:ensure_updated_shipments)
|
|
142
|
-
expect(shipment).to receive(:update_amounts)
|
|
143
|
-
subject.remove(variant, 1, shipment: shipment)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
context 'not given a shipment' do
|
|
148
|
-
it "ensures updated shipments" do
|
|
149
|
-
line_item = subject.add(variant, 1)
|
|
150
|
-
expect(subject.order).to receive(:ensure_updated_shipments)
|
|
151
|
-
subject.remove(variant)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it 'should reduce line_item quantity if quantity is less the line_item quantity' do
|
|
156
|
-
line_item = subject.add(variant, 3)
|
|
157
|
-
subject.remove(variant, 1)
|
|
158
|
-
|
|
159
|
-
expect(line_item.quantity).to eq(2)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it 'should remove line_item if quantity matches line_item quantity' do
|
|
163
|
-
subject.add(variant, 1)
|
|
164
|
-
removed_line_item = subject.remove(variant, 1)
|
|
165
|
-
|
|
166
|
-
# Should reflect the change already in Order#line_item
|
|
167
|
-
expect(order.line_items).to_not include(removed_line_item)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it "should update order totals" do
|
|
171
|
-
expect(order.item_total.to_f).to eq(0.00)
|
|
172
|
-
expect(order.total.to_f).to eq(0.00)
|
|
173
|
-
|
|
174
|
-
subject.add(variant,2)
|
|
175
|
-
|
|
176
|
-
expect(order.item_total.to_f).to eq(39.98)
|
|
177
|
-
expect(order.total.to_f).to eq(39.98)
|
|
178
|
-
|
|
179
|
-
subject.remove(variant,1)
|
|
180
|
-
expect(order.item_total.to_f).to eq(19.99)
|
|
181
|
-
expect(order.total.to_f).to eq(19.99)
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
context "#remove_line_item" do
|
|
186
|
-
context 'given a shipment' do
|
|
187
|
-
it "ensure shipment calls update_amounts instead of order calling ensure_updated_shipments" do
|
|
188
|
-
line_item = subject.add(variant, 1)
|
|
189
|
-
shipment = create(:shipment)
|
|
190
|
-
expect(subject.order).to_not receive(:ensure_updated_shipments)
|
|
191
|
-
expect(shipment).to receive(:update_amounts)
|
|
192
|
-
subject.remove_line_item(line_item, shipment: shipment)
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
context 'not given a shipment' do
|
|
197
|
-
it "ensures updated shipments" do
|
|
198
|
-
line_item = subject.add(variant, 1)
|
|
199
|
-
expect(subject.order).to receive(:ensure_updated_shipments)
|
|
200
|
-
subject.remove_line_item(line_item)
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it 'should remove line_item' do
|
|
205
|
-
line_item = subject.add(variant, 1)
|
|
206
|
-
subject.remove_line_item(line_item)
|
|
207
|
-
|
|
208
|
-
expect(order.reload.line_items).to_not include(line_item)
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
it "should update order totals" do
|
|
212
|
-
expect(order.item_total.to_f).to eq(0.00)
|
|
213
|
-
expect(order.total.to_f).to eq(0.00)
|
|
214
|
-
|
|
215
|
-
line_item = subject.add(variant,2)
|
|
216
|
-
|
|
217
|
-
expect(order.item_total.to_f).to eq(39.98)
|
|
218
|
-
expect(order.total.to_f).to eq(39.98)
|
|
219
|
-
|
|
220
|
-
subject.remove_line_item(line_item)
|
|
221
|
-
expect(order.item_total.to_f).to eq(0.00)
|
|
222
|
-
expect(order.total.to_f).to eq(0.00)
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
context "update cart" do
|
|
227
|
-
let!(:shirt) { subject.add variant, 1 }
|
|
228
|
-
|
|
229
|
-
let(:params) do
|
|
230
|
-
{ line_items_attributes: {
|
|
231
|
-
"0" => { id: shirt.id, quantity: 3 }
|
|
232
|
-
} }
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it "changes item quantity" do
|
|
236
|
-
subject.update_cart params
|
|
237
|
-
expect(shirt.quantity).to eq 3
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it "updates order totals" do
|
|
241
|
-
expect {
|
|
242
|
-
subject.update_cart params
|
|
243
|
-
}.to change { subject.order.total }
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
context "submits item quantity 0" do
|
|
247
|
-
let(:params) do
|
|
248
|
-
{ line_items_attributes: {
|
|
249
|
-
"0" => { id: shirt.id, quantity: 0 },
|
|
250
|
-
"1" => { id: "666", quantity: 0}
|
|
251
|
-
} }
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it "removes item from order" do
|
|
255
|
-
expect {
|
|
256
|
-
subject.update_cart params
|
|
257
|
-
}.to change { subject.order.line_items.count }
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
it "doesnt try to update unexistent items" do
|
|
261
|
-
filtered_params = { line_items_attributes: {
|
|
262
|
-
"0" => { id: shirt.id, quantity: 0 },
|
|
263
|
-
} }
|
|
264
|
-
expect(subject.order).to receive(:update_attributes).with(filtered_params)
|
|
265
|
-
subject.update_cart params
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
it "should not filter if there is only one line item" do
|
|
269
|
-
single_line_item_params = { line_items_attributes: { id: shirt.id, quantity: 0 } }
|
|
270
|
-
expect(subject.order).to receive(:update_attributes).with(single_line_item_params)
|
|
271
|
-
subject.update_cart single_line_item_params
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
it "ensures updated shipments" do
|
|
277
|
-
expect(subject.order).to receive(:ensure_updated_shipments)
|
|
278
|
-
subject.update_cart params
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
context "completed order" do
|
|
283
|
-
let(:order) { create(:order, state: 'complete', completed_at: Time.current) }
|
|
284
|
-
|
|
285
|
-
before { order.shipments.create! stock_location_id: variant.stock_location_ids.first }
|
|
286
|
-
|
|
287
|
-
it "updates order payment state" do
|
|
288
|
-
expect {
|
|
289
|
-
subject.add variant
|
|
290
|
-
}.to change { order.payment_state }
|
|
291
|
-
|
|
292
|
-
expect {
|
|
293
|
-
subject.remove variant
|
|
294
|
-
}.to change { order.payment_state }
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
end
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Spree::OrderInventory, type: :model do
|
|
4
|
-
let(:order) { create :completed_order_with_totals }
|
|
5
|
-
let(:line_item) { order.line_items.first }
|
|
6
|
-
|
|
7
|
-
subject { described_class.new(order, line_item) }
|
|
8
|
-
|
|
9
|
-
describe 'delegate' do
|
|
10
|
-
it { is_expected.to delegate_method(:inventory_units).to(:line_item) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when order is missing inventory units" do
|
|
14
|
-
before { line_item.update_column(:quantity, 2) }
|
|
15
|
-
|
|
16
|
-
it 'creates the proper number of inventory units' do
|
|
17
|
-
subject.verify
|
|
18
|
-
expect(subject.inventory_units.count).to eq 2
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context "#add_to_shipment" do
|
|
23
|
-
let(:shipment) { order.shipments.first }
|
|
24
|
-
|
|
25
|
-
context "order is not completed" do
|
|
26
|
-
before { allow(order).to receive_messages completed?: false }
|
|
27
|
-
|
|
28
|
-
it "doesn't unstock items" do
|
|
29
|
-
expect(shipment.stock_location).not_to receive(:unstock)
|
|
30
|
-
expect(subject.send(:add_to_shipment, shipment, 5)).to eq(5)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "inventory units state" do
|
|
35
|
-
before { shipment.inventory_units.destroy_all }
|
|
36
|
-
|
|
37
|
-
it 'sets inventory_units state as per stock location availability' do
|
|
38
|
-
expect(shipment.stock_location).to receive(:fill_status).with(subject.variant, 5).and_return([3, 2])
|
|
39
|
-
|
|
40
|
-
expect(subject.send(:add_to_shipment, shipment, 5)).to eq(5)
|
|
41
|
-
|
|
42
|
-
units = shipment.inventory_units_for(subject.variant).group_by(&:state)
|
|
43
|
-
expect(units['backordered'].size).to eq(2)
|
|
44
|
-
expect(units['on_hand'].size).to eq(3)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "store doesnt track inventory" do
|
|
49
|
-
let(:variant) { create(:variant) }
|
|
50
|
-
|
|
51
|
-
before { Spree::Config.track_inventory_levels = false }
|
|
52
|
-
|
|
53
|
-
it "creates only on hand inventory units" do
|
|
54
|
-
variant.stock_items.destroy_all
|
|
55
|
-
|
|
56
|
-
# The before_save callback in LineItem would verify inventory
|
|
57
|
-
line_item = order.contents.add variant, 1, shipment: shipment
|
|
58
|
-
|
|
59
|
-
units = shipment.inventory_units_for(line_item.variant)
|
|
60
|
-
expect(units.count).to eq 1
|
|
61
|
-
expect(units.first).to be_on_hand
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context "variant doesnt track inventory" do
|
|
66
|
-
let(:variant) { create(:variant) }
|
|
67
|
-
before { variant.track_inventory = false }
|
|
68
|
-
|
|
69
|
-
it "creates only on hand inventory units" do
|
|
70
|
-
variant.stock_items.destroy_all
|
|
71
|
-
|
|
72
|
-
line_item = order.contents.add variant, 1
|
|
73
|
-
subject.verify(shipment)
|
|
74
|
-
|
|
75
|
-
units = shipment.inventory_units_for(line_item.variant)
|
|
76
|
-
expect(units.count).to eq 1
|
|
77
|
-
expect(units.first).to be_on_hand
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it 'should create stock_movement' do
|
|
82
|
-
expect(subject.send(:add_to_shipment, shipment, 5)).to eq(5)
|
|
83
|
-
|
|
84
|
-
stock_item = shipment.stock_location.stock_item(subject.variant)
|
|
85
|
-
movement = stock_item.stock_movements.last
|
|
86
|
-
# movement.originator.should == shipment
|
|
87
|
-
expect(movement.quantity).to eq(-5)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context "#determine_target_shipment" do
|
|
92
|
-
let(:stock_location) { create :stock_location }
|
|
93
|
-
let(:variant) { line_item.variant }
|
|
94
|
-
|
|
95
|
-
before do
|
|
96
|
-
allow(line_item).to receive(:changed?).and_return(:true)
|
|
97
|
-
subject.verify
|
|
98
|
-
|
|
99
|
-
order.shipments.create(stock_location_id: stock_location.id, cost: 5)
|
|
100
|
-
|
|
101
|
-
shipped = order.shipments.create(stock_location_id: order.shipments.first.stock_location.id, cost: 10)
|
|
102
|
-
shipped.update_column(:state, 'shipped')
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'should select first non-shipped shipment that already contains given variant' do
|
|
106
|
-
shipment = subject.send(:determine_target_shipment)
|
|
107
|
-
expect(shipment.shipped?).to be false
|
|
108
|
-
expect(shipment.inventory_units_for(variant)).not_to be_empty
|
|
109
|
-
|
|
110
|
-
expect(variant.stock_location_ids.include?(shipment.stock_location_id)).to be true
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
context "when no shipments already contain this varint" do
|
|
114
|
-
before do
|
|
115
|
-
subject.line_item.reload
|
|
116
|
-
subject.inventory_units.destroy_all
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it 'selects first non-shipped shipment that leaves from same stock_location' do
|
|
120
|
-
shipment = subject.send(:determine_target_shipment)
|
|
121
|
-
shipment.reload
|
|
122
|
-
expect(shipment.shipped?).to be false
|
|
123
|
-
expect(shipment.inventory_units_for(variant)).to be_empty
|
|
124
|
-
expect(variant.stock_location_ids.include?(shipment.stock_location_id)).to be true
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
context 'when order has too many inventory units' do
|
|
130
|
-
before do
|
|
131
|
-
line_item.quantity = 3
|
|
132
|
-
line_item.save!
|
|
133
|
-
|
|
134
|
-
line_item.update_column(:quantity, 2)
|
|
135
|
-
subject.line_item.reload
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it 'should be a messed up order' do
|
|
139
|
-
expect(order.shipments.first.inventory_units_for(line_item.variant).size).to eq(3)
|
|
140
|
-
expect(line_item.quantity).to eq(2)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it 'should decrease the number of inventory units' do
|
|
144
|
-
subject.verify
|
|
145
|
-
expect(subject.inventory_units.count).to eq 2
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
context '#remove_from_shipment' do
|
|
149
|
-
let(:shipment) { order.shipments.first }
|
|
150
|
-
let(:variant) { subject.variant }
|
|
151
|
-
|
|
152
|
-
context "order is not completed" do
|
|
153
|
-
before { allow(order).to receive_messages completed?: false }
|
|
154
|
-
|
|
155
|
-
it "doesn't restock items" do
|
|
156
|
-
expect(shipment.stock_location).not_to receive(:restock)
|
|
157
|
-
expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
it 'should create stock_movement' do
|
|
162
|
-
expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)
|
|
163
|
-
|
|
164
|
-
stock_item = shipment.stock_location.stock_item(variant)
|
|
165
|
-
movement = stock_item.stock_movements.last
|
|
166
|
-
# movement.originator.should == shipment
|
|
167
|
-
expect(movement.quantity).to eq(1)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it 'should destroy backordered units first' do
|
|
171
|
-
allow(shipment).to receive_messages(
|
|
172
|
-
inventory_units_for_item: [
|
|
173
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'backordered', shipped?: false),
|
|
174
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'on_hand', shipped?: false),
|
|
175
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'backordered', shipped?: false)
|
|
176
|
-
]
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
expect(shipment.inventory_units_for_item[0]).to receive(:destroy)
|
|
180
|
-
expect(shipment.inventory_units_for_item[1]).not_to receive(:destroy)
|
|
181
|
-
expect(shipment.inventory_units_for_item[2]).to receive(:destroy)
|
|
182
|
-
|
|
183
|
-
expect(subject.send(:remove_from_shipment, shipment, 2)).to eq(2)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it 'should destroy unshipped units first' do
|
|
187
|
-
allow(shipment).to receive_messages(
|
|
188
|
-
inventory_units_for_item: [
|
|
189
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'shipped', shipped?: true),
|
|
190
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'on_hand', shipped?: false)
|
|
191
|
-
]
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
expect(shipment.inventory_units_for_item[0]).not_to receive(:destroy)
|
|
195
|
-
expect(shipment.inventory_units_for_item[1]).to receive(:destroy)
|
|
196
|
-
|
|
197
|
-
expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it 'only attempts to destroy as many units as are eligible, and return amount destroyed' do
|
|
201
|
-
allow(shipment).to receive_messages(
|
|
202
|
-
inventory_units_for_item: [
|
|
203
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'shipped', shipped?: true),
|
|
204
|
-
mock_model(Spree::InventoryUnit, variant_id: variant.id, state: 'on_hand', shipped?: false)
|
|
205
|
-
]
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
expect(shipment.inventory_units_for_item[0]).not_to receive(:destroy)
|
|
209
|
-
expect(shipment.inventory_units_for_item[1]).to receive(:destroy)
|
|
210
|
-
|
|
211
|
-
expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it 'should destroy self if not inventory units remain' do
|
|
215
|
-
allow(shipment.inventory_units).to receive_messages(count: 0)
|
|
216
|
-
expect(shipment).to receive(:destroy)
|
|
217
|
-
|
|
218
|
-
expect(subject.send(:remove_from_shipment, shipment, 1)).to eq(1)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
context "inventory unit line item and variant points to different products" do
|
|
222
|
-
let(:different_line_item) { create(:line_item) }
|
|
223
|
-
|
|
224
|
-
let!(:different_inventory) do
|
|
225
|
-
shipment.set_up_inventory("on_hand", variant, order, different_line_item)
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
context "completed order" do
|
|
229
|
-
before { order.touch :completed_at }
|
|
230
|
-
|
|
231
|
-
it "removes only units that match both line item and variant" do
|
|
232
|
-
subject.send(:remove_from_shipment, shipment, shipment.inventory_units.count)
|
|
233
|
-
expect(different_inventory.reload).to be_persisted
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
end
|