solidus_core 2.9.5 → 2.10.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/app/helpers/spree/base_helper.rb +4 -4
- data/app/helpers/spree/products_helper.rb +2 -1
- data/app/jobs/spree/promotion_code_batch_job.rb +2 -2
- data/app/models/concerns/spree/user_address_book.rb +2 -2
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +13 -17
- data/app/models/spree/adjustment.rb +20 -9
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/base.rb +0 -2
- data/app/models/spree/calculator.rb +1 -1
- data/app/models/spree/calculator/price_sack.rb +1 -1
- data/app/models/spree/calculator/shipping/flexi_rate.rb +2 -2
- data/app/models/spree/calculator/tiered_flat_rate.rb +5 -5
- data/app/models/spree/calculator/tiered_percent.rb +6 -6
- data/app/models/spree/carton.rb +3 -3
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/credit_card.rb +4 -4
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/inventory_unit.rb +5 -23
- data/app/models/spree/line_item.rb +4 -4
- data/app/models/spree/line_item_action.rb +2 -2
- data/app/models/spree/log_entry.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/option_values_variant.rb +2 -2
- data/app/models/spree/order.rb +11 -27
- data/app/models/spree/order/checkout.rb +1 -1
- data/app/models/spree/order/payments.rb +2 -2
- data/app/models/spree/order_cancellations.rb +1 -1
- data/app/models/spree/order_capturing.rb +2 -2
- data/app/models/spree/order_contents.rb +2 -2
- data/app/models/spree/order_mutex.rb +1 -1
- data/app/models/spree/order_promotion.rb +3 -3
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/order_taxation.rb +3 -3
- data/app/models/spree/payment.rb +8 -45
- data/app/models/spree/payment/processing.rb +3 -3
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/payment_method.rb +5 -2
- data/app/models/spree/payment_method/bogus_credit_card.rb +1 -1
- data/app/models/spree/payment_source.rb +1 -1
- data/app/models/spree/price.rb +2 -2
- data/app/models/spree/product.rb +5 -5
- data/app/models/spree/product/scopes.rb +218 -210
- data/app/models/spree/product_option_type.rb +2 -2
- data/app/models/spree/product_promotion_rule.rb +2 -2
- data/app/models/spree/product_property.rb +2 -2
- data/app/models/spree/promotion.rb +28 -13
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +1 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/option_value.rb +2 -2
- data/app/models/spree/promotion/rules/product.rb +3 -3
- data/app/models/spree/promotion_action.rb +2 -2
- data/app/models/spree/promotion_chooser.rb +2 -2
- data/app/models/spree/promotion_code.rb +11 -10
- data/app/models/spree/promotion_code/batch_builder.rb +3 -3
- data/app/models/spree/promotion_code_batch.rb +1 -1
- data/app/models/spree/promotion_rule.rb +2 -2
- data/app/models/spree/promotion_rule_role.rb +2 -2
- data/app/models/spree/promotion_rule_store.rb +2 -2
- data/app/models/spree/promotion_rule_taxon.rb +2 -2
- data/app/models/spree/promotion_rule_user.rb +2 -2
- data/app/models/spree/refund.rb +5 -5
- data/app/models/spree/reimbursement.rb +5 -13
- data/app/models/spree/reimbursement/credit.rb +2 -2
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -1
- data/app/models/spree/reimbursement_tax_calculator.rb +1 -1
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +2 -2
- data/app/models/spree/return_authorization.rb +4 -10
- data/app/models/spree/return_item.rb +13 -52
- data/app/models/spree/return_item/eligibility_validator/default.rb +1 -1
- data/app/models/spree/role_user.rb +2 -2
- data/app/models/spree/shipment.rb +7 -41
- data/app/models/spree/shipping_calculator.rb +0 -4
- data/app/models/spree/shipping_manifest.rb +3 -3
- data/app/models/spree/shipping_method.rb +2 -2
- data/app/models/spree/shipping_method_category.rb +2 -2
- data/app/models/spree/shipping_method_stock_location.rb +2 -2
- data/app/models/spree/shipping_method_zone.rb +2 -2
- data/app/models/spree/shipping_rate.rb +2 -2
- data/app/models/spree/shipping_rate_tax.rb +2 -2
- data/app/models/spree/state.rb +2 -2
- data/app/models/spree/state_change.rb +2 -2
- data/app/models/spree/stock/differentiator.rb +1 -1
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock_item.rb +3 -3
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/stock_quantities.rb +13 -12
- data/app/models/spree/store_credit.rb +8 -8
- data/app/models/spree/store_credit_event.rb +3 -3
- data/app/models/spree/store_payment_method.rb +2 -2
- data/app/models/spree/store_shipping_method.rb +2 -2
- data/app/models/spree/tax_calculator/default.rb +0 -4
- data/app/models/spree/tax_calculator/shipping_rate.rb +0 -3
- data/app/models/spree/tax_rate.rb +5 -1
- data/app/models/spree/tax_rate_tax_category.rb +2 -2
- data/app/models/spree/taxon/paperclip_attachment.rb +13 -0
- data/app/models/spree/unit_cancel.rb +5 -2
- data/app/models/spree/user_address.rb +2 -2
- data/app/models/spree/user_last_url_storer.rb +46 -0
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +36 -0
- data/app/models/spree/user_stock_location.rb +2 -2
- data/app/models/spree/variant.rb +10 -10
- data/app/models/spree/variant/scopes.rb +37 -29
- data/app/models/spree/variant_property_rule.rb +1 -1
- data/app/models/spree/variant_property_rule_condition.rb +2 -2
- data/app/models/spree/variant_property_rule_value.rb +2 -2
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
- data/app/models/spree/wallet_payment_source.rb +2 -2
- data/app/models/spree/zone.rb +1 -1
- data/app/models/spree/zone_member.rb +2 -2
- data/config/initializers/inflections.rb +5 -0
- data/config/initializers/money.rb +2 -0
- data/config/locales/en.yml +34 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -0
- data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +8 -0
- data/lib/spree/app_configuration.rb +18 -3
- data/lib/spree/core.rb +12 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -13
- data/lib/spree/core/controller_helpers/strong_parameters.rb +21 -7
- data/lib/spree/core/engine.rb +2 -2
- data/lib/spree/core/importer/order.rb +29 -28
- data/lib/spree/core/importer/product.rb +2 -2
- data/lib/spree/core/product_filters.rb +15 -15
- data/lib/spree/core/role_configuration.rb +2 -2
- data/lib/spree/core/search/variant.rb +1 -1
- data/lib/spree/core/state_machines.rb +78 -0
- data/lib/spree/core/state_machines/inventory_unit.rb +42 -0
- data/lib/spree/core/state_machines/payment.rb +61 -0
- data/lib/spree/core/state_machines/reimbursement.rb +33 -0
- data/lib/spree/core/state_machines/return_authorization.rb +32 -0
- data/lib/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
- data/lib/spree/core/state_machines/return_item/reception_status.rb +42 -0
- data/lib/spree/core/state_machines/shipment.rb +58 -0
- data/lib/spree/core/stock_configuration.rb +1 -0
- data/lib/spree/core/validators/email.rb +1 -8
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +2 -2
- data/lib/spree/permission_sets/default_customer.rb +1 -1
- data/lib/spree/permission_sets/user_management.rb +3 -0
- data/lib/spree/permitted_attributes.rb +78 -9
- data/lib/spree/preferences/static_model_preferences.rb +2 -2
- data/lib/spree/testing_support/dummy_app.rb +4 -1
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +6 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +8 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -0
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -1
- data/solidus_core.gemspec +6 -6
- data/spec/lib/search/base_spec.rb +5 -1
- data/spec/lib/search/variant_spec.rb +1 -1
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +8 -1
- data/spec/lib/spree/core/stock_configuration_spec.rb +36 -0
- data/spec/lib/spree/core/validators/email_spec.rb +18 -18
- data/spec/lib/spree/event_spec.rb +15 -3
- data/spec/lib/spree/permitted_attributes_spec.rb +41 -0
- data/spec/models/spree/ability_spec.rb +1 -1
- data/spec/models/spree/address_spec.rb +23 -0
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +24 -15
- data/spec/models/spree/carton_spec.rb +10 -2
- data/spec/models/spree/classification_spec.rb +21 -9
- data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
- data/spec/models/spree/concerns/user_methods_spec.rb +5 -4
- data/spec/models/spree/credit_card_spec.rb +2 -2
- data/spec/models/spree/customer_return_spec.rb +1 -1
- data/spec/models/spree/order/checkout_spec.rb +1 -1
- data/spec/models/spree/order/outstanding_balance_integration_spec.rb +5 -5
- data/spec/models/spree/order/payment_spec.rb +1 -1
- data/spec/models/spree/order_contents_spec.rb +1 -1
- data/spec/models/spree/order_inventory_spec.rb +3 -3
- data/spec/models/spree/order_merger_spec.rb +3 -3
- data/spec/models/spree/order_shipping_spec.rb +1 -1
- data/spec/models/spree/order_spec.rb +14 -21
- data/spec/models/spree/order_updater_spec.rb +4 -3
- data/spec/models/spree/payment_create_spec.rb +6 -16
- data/spec/models/spree/payment_spec.rb +12 -12
- data/spec/models/spree/permission_sets/user_management_spec.rb +2 -0
- data/spec/models/spree/preference_spec.rb +4 -4
- data/spec/models/spree/preferences/preferable_spec.rb +3 -3
- data/spec/models/spree/preferences/statically_configurable_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/nth_order_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/taxon_spec.rb +1 -0
- data/spec/models/spree/promotion_rule_spec.rb +6 -6
- data/spec/models/spree/promotion_spec.rb +71 -54
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +3 -3
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +1 -1
- data/spec/models/spree/return_item_spec.rb +11 -11
- data/spec/models/spree/returns_calculator_spec.rb +2 -2
- data/spec/models/spree/shipment_spec.rb +6 -6
- data/spec/models/spree/shipping_calculator_spec.rb +1 -13
- data/spec/models/spree/shipping_method_spec.rb +32 -0
- data/spec/models/spree/stock/availability_validator_spec.rb +2 -2
- data/spec/models/spree/stock/differentiator_spec.rb +2 -2
- data/spec/models/spree/stock/estimator_spec.rb +3 -3
- data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +4 -4
- data/spec/models/spree/stock/package_spec.rb +28 -28
- data/spec/models/spree/stock/quantifier_spec.rb +2 -2
- data/spec/models/spree/stock/simple_coordinator_spec.rb +11 -11
- data/spec/models/spree/stock/splitter/base_spec.rb +4 -4
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +7 -7
- data/spec/models/spree/stock_quantities_spec.rb +1 -1
- data/spec/models/spree/store_credit_spec.rb +8 -8
- data/spec/models/spree/tax_category_spec.rb +1 -1
- data/spec/models/spree/tax_rate_spec.rb +1 -0
- data/spec/models/spree/taxon_spec.rb +2 -2
- data/spec/models/spree/taxons/paperclip_attachment_spec.rb +29 -0
- data/spec/models/spree/unit_cancel_spec.rb +5 -0
- data/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb +31 -0
- data/spec/models/spree/user_last_url_storer_spec.rb +60 -0
- data/spec/models/spree/user_spec.rb +3 -3
- metadata +46 -39
- data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +0 -148
- data/spec/models/spree/order/updating_spec.rb +0 -18
|
@@ -19,11 +19,11 @@ module Spree
|
|
|
19
19
|
let(:order) { mock_model(Order, line_items: [line_item1, line_item2]) }
|
|
20
20
|
|
|
21
21
|
let(:package1) do
|
|
22
|
-
Package.new(stock_location).tap { |
|
|
22
|
+
Package.new(stock_location).tap { |package| package.add(inventory_unit1) }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
let(:package2) do
|
|
26
|
-
Package.new(stock_location).tap { |
|
|
26
|
+
Package.new(stock_location).tap { |package| package.add(inventory_unit2) }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
let(:packages) { [package1, package2] }
|
|
@@ -8,8 +8,8 @@ module Spree
|
|
|
8
8
|
let(:shipping_rate) { 4.00 }
|
|
9
9
|
let!(:shipping_method) { create(:shipping_method, cost: shipping_rate, currency: currency) }
|
|
10
10
|
let(:package) do
|
|
11
|
-
build(:stock_package, contents: inventory_units.map { |
|
|
12
|
-
|
|
11
|
+
build(:stock_package, contents: inventory_units.map { |unit| ContentItem.new(unit) }).tap do |package|
|
|
12
|
+
package.shipment = package.to_shipment
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
let(:order) { create(:order_with_line_items, shipping_method: shipping_method) }
|
|
@@ -61,7 +61,7 @@ module Spree
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
context "when the order's ship address is in a different zone" do
|
|
64
|
-
before { shipping_method.zones.each{ |
|
|
64
|
+
before { shipping_method.zones.each{ |zone| zone.members.delete_all } }
|
|
65
65
|
it_should_behave_like "shipping rate doesn't match"
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -12,8 +12,8 @@ module Spree
|
|
|
12
12
|
|
|
13
13
|
before do
|
|
14
14
|
stock_item.set_count_on_hand(10)
|
|
15
|
-
stock_item.
|
|
16
|
-
inventory_unit.
|
|
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.
|
|
46
|
-
inventory_unit_2.
|
|
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! }
|
|
@@ -51,41 +51,41 @@ module Spree
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it 'builds the correct list of shipping methods based on stock location and categories' do
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
contents = [ContentItem.new(build(:inventory_unit, variant:
|
|
64
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
65
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
66
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
54
|
+
category_one = create(:shipping_category)
|
|
55
|
+
category_two = create(:shipping_category)
|
|
56
|
+
method_one = create(:shipping_method, available_to_all: true)
|
|
57
|
+
method_two = create(:shipping_method, stock_locations: [stock_location])
|
|
58
|
+
method_one.shipping_categories = [category_one, category_two]
|
|
59
|
+
method_two.shipping_categories = [category_one, category_two]
|
|
60
|
+
variant_one = mock_model(Variant, shipping_category_id: category_one.id)
|
|
61
|
+
variant_two = mock_model(Variant, shipping_category_id: category_two.id)
|
|
62
|
+
variant_three = mock_model(Variant, shipping_category_id: nil)
|
|
63
|
+
contents = [ContentItem.new(build(:inventory_unit, variant: variant_one)),
|
|
64
|
+
ContentItem.new(build(:inventory_unit, variant: variant_one)),
|
|
65
|
+
ContentItem.new(build(:inventory_unit, variant: variant_two)),
|
|
66
|
+
ContentItem.new(build(:inventory_unit, variant: variant_three))]
|
|
67
67
|
|
|
68
68
|
package = Package.new(stock_location, contents)
|
|
69
|
-
expect(package.shipping_methods).to match_array([
|
|
69
|
+
expect(package.shipping_methods).to match_array([method_one, method_two])
|
|
70
70
|
end
|
|
71
71
|
# Contains regression test for https://github.com/spree/spree/issues/2804
|
|
72
72
|
it 'builds a list of shipping methods common to all categories' do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
contents = [ContentItem.new(build(:inventory_unit, variant:
|
|
83
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
84
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
85
|
-
ContentItem.new(build(:inventory_unit, variant:
|
|
73
|
+
category_one = create(:shipping_category)
|
|
74
|
+
category_two = create(:shipping_category)
|
|
75
|
+
method_one = create(:shipping_method)
|
|
76
|
+
method_two = create(:shipping_method)
|
|
77
|
+
method_one.shipping_categories = [category_one, category_two]
|
|
78
|
+
method_two.shipping_categories = [category_one]
|
|
79
|
+
variant_one = mock_model(Variant, shipping_category_id: category_one.id)
|
|
80
|
+
variant_two = mock_model(Variant, shipping_category_id: category_two.id)
|
|
81
|
+
variant_three = mock_model(Variant, shipping_category_id: nil)
|
|
82
|
+
contents = [ContentItem.new(build(:inventory_unit, variant: variant_one)),
|
|
83
|
+
ContentItem.new(build(:inventory_unit, variant: variant_one)),
|
|
84
|
+
ContentItem.new(build(:inventory_unit, variant: variant_two)),
|
|
85
|
+
ContentItem.new(build(:inventory_unit, variant: variant_three))]
|
|
86
86
|
|
|
87
87
|
package = Package.new(stock_location, contents)
|
|
88
|
-
expect(package.shipping_methods).to match_array([
|
|
88
|
+
expect(package.shipping_methods).to match_array([method_one])
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it 'builds an empty list of shipping methods when no categories' do
|
|
@@ -49,7 +49,7 @@ module Spree
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
context 'when stock item prevents backordering' do
|
|
52
|
-
before { stock_item.
|
|
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.
|
|
84
|
+
before { stock_item.update(backorderable: false) }
|
|
85
85
|
|
|
86
86
|
specify { expect(subject.backorderable?).to be false }
|
|
87
87
|
|
|
@@ -90,8 +90,8 @@ module Spree
|
|
|
90
90
|
|
|
91
91
|
expect(shipments.size).to eq 2
|
|
92
92
|
|
|
93
|
-
location_1_shipment = shipments.detect { |
|
|
94
|
-
location_2_shipment = shipments.detect { |
|
|
93
|
+
location_1_shipment = shipments.detect { |shipment| shipment.stock_location == stock_location_1 }
|
|
94
|
+
location_2_shipment = shipments.detect { |shipment| shipment.stock_location == stock_location_2 }
|
|
95
95
|
|
|
96
96
|
expect(location_1_shipment).to be_present
|
|
97
97
|
expect(location_2_shipment).to be_present
|
|
@@ -107,8 +107,8 @@ module Spree
|
|
|
107
107
|
let!(:variant) { create(:variant, track_inventory: true) }
|
|
108
108
|
|
|
109
109
|
before do
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
stock_item_one = variant.stock_items.create!(stock_location: stock_location_1, backorderable: false)
|
|
111
|
+
stock_item_one.set_count_on_hand(location_1_inventory)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
let!(:order) { create(:order) }
|
|
@@ -119,7 +119,7 @@ module Spree
|
|
|
119
119
|
shared_examples "a fulfillable package" do
|
|
120
120
|
it "packages correctly" do
|
|
121
121
|
expect(shipments).not_to be_empty
|
|
122
|
-
inventory_units = shipments.flat_map { |
|
|
122
|
+
inventory_units = shipments.flat_map { |shipment| shipment.inventory_units }
|
|
123
123
|
expect(inventory_units.size).to eq(5)
|
|
124
124
|
expect(inventory_units.uniq.size).to eq(5)
|
|
125
125
|
end
|
|
@@ -157,8 +157,8 @@ module Spree
|
|
|
157
157
|
context 'with two stock locations' do
|
|
158
158
|
let!(:stock_location_2) { create(:stock_location, propagate_all_variants: false, active: true) }
|
|
159
159
|
before do
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
stock_item_two = variant.stock_items.create!(stock_location: stock_location_2, backorderable: false)
|
|
161
|
+
stock_item_two.set_count_on_hand(location_2_inventory)
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
context "with no inventory" do
|
|
@@ -214,11 +214,11 @@ module Spree
|
|
|
214
214
|
let!(:stock_location_2) { create(:stock_location, propagate_all_variants: false, active: true) }
|
|
215
215
|
let!(:stock_location_3) { create(:stock_location, propagate_all_variants: false, active: true) }
|
|
216
216
|
before do
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
stock_item_two = variant.stock_items.create!(stock_location: stock_location_2, backorderable: false)
|
|
218
|
+
stock_item_two.set_count_on_hand(location_2_inventory)
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
stock_item_three = variant.stock_items.create!(stock_location: stock_location_3, backorderable: false)
|
|
221
|
+
stock_item_three.set_count_on_hand(location_3_inventory)
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
# Regression test for https://github.com/solidusio/solidus/issues/2122
|
|
@@ -9,12 +9,12 @@ module Spree
|
|
|
9
9
|
let(:stock_location) { mock_model(Spree::StockLocation) }
|
|
10
10
|
|
|
11
11
|
it 'continues to splitter chain' do
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
splitter_one = Base.new(stock_location)
|
|
13
|
+
splitter_two = Base.new(stock_location, splitter_one)
|
|
14
14
|
packages = []
|
|
15
15
|
|
|
16
|
-
expect(
|
|
17
|
-
|
|
16
|
+
expect(splitter_one).to receive(:split).with(packages)
|
|
17
|
+
splitter_two.split(packages)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -29,15 +29,15 @@ module Spree
|
|
|
29
29
|
subject { described_class.new(stock_location) }
|
|
30
30
|
|
|
31
31
|
it 'splits each package by shipping category' do
|
|
32
|
-
|
|
33
|
-
4.times {
|
|
34
|
-
8.times {
|
|
32
|
+
package_one = Package.new(stock_location)
|
|
33
|
+
4.times { package_one.add inventory_unit1 }
|
|
34
|
+
8.times { package_one.add inventory_unit2 }
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
6.times {
|
|
38
|
-
9.times {
|
|
36
|
+
package_two = Package.new(stock_location)
|
|
37
|
+
6.times { package_two.add inventory_unit1 }
|
|
38
|
+
9.times { package_two.add inventory_unit2, :backordered }
|
|
39
39
|
|
|
40
|
-
packages = subject.split([
|
|
40
|
+
packages = subject.split([package_one, package_two])
|
|
41
41
|
expect(packages[0].quantity).to eq 4
|
|
42
42
|
expect(packages[1].quantity).to eq 8
|
|
43
43
|
expect(packages[2].quantity).to eq 6
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
@@ -777,7 +777,7 @@ RSpec.describe Spree::StoreCredit do
|
|
|
777
777
|
let!(:store_credits) do
|
|
778
778
|
[
|
|
779
779
|
create(:store_credit, user: user, amount: store_credit_amount),
|
|
780
|
-
create(:store_credit, user: user, amount: additional_store_credit_amount)
|
|
780
|
+
create(:store_credit, user: user.reload, amount: additional_store_credit_amount)
|
|
781
781
|
]
|
|
782
782
|
end
|
|
783
783
|
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe "Spree::Taxon::PaperclipAttachment", type: :model do
|
|
6
|
+
describe "#destroy_attachment" do
|
|
7
|
+
let(:taxon) { create(:taxon) }
|
|
8
|
+
|
|
9
|
+
context "when trying to destroy a valid attachment definition" do
|
|
10
|
+
context "and taxon has a file attached " do
|
|
11
|
+
it "removes the attachment" do
|
|
12
|
+
taxon.update(icon: File.new(Rails.root.join('..', '..', 'spec', 'fixtures', 'thinking-cat.jpg')))
|
|
13
|
+
expect(taxon.destroy_attachment(:icon)).to be_truthy
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
context "and the taxon does not have any file attached yet" do
|
|
17
|
+
it "returns false" do
|
|
18
|
+
expect(taxon.destroy_attachment(:icon)).to be_falsey
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when trying to destroy an invalid attachment" do
|
|
24
|
+
it 'returns false' do
|
|
25
|
+
expect(taxon.destroy_attachment(:foo)).to be_falsey
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -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
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Spree::UserLastUrlStorer::Rules::AuthenticationRule do
|
|
6
|
+
describe '#match?' do
|
|
7
|
+
let(:login_path) { '/sign_in' }
|
|
8
|
+
let(:request) { double(fullpath: fullpath) }
|
|
9
|
+
let(:controller) do
|
|
10
|
+
double(
|
|
11
|
+
request: request,
|
|
12
|
+
spree_login_path: login_path,
|
|
13
|
+
controller_name: 'controller_double'
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
subject { described_class.match?(controller) }
|
|
18
|
+
|
|
19
|
+
context 'when the request full path is an authentication route' do
|
|
20
|
+
let!(:fullpath) { login_path }
|
|
21
|
+
|
|
22
|
+
it { is_expected.to be true }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context 'when the request full path is not an authentication route' do
|
|
26
|
+
let!(:fullpath) { '/products/baseball-cap' }
|
|
27
|
+
|
|
28
|
+
it { is_expected.to be false }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Spree::UserLastUrlStorer do
|
|
6
|
+
subject { described_class.new(controller) }
|
|
7
|
+
|
|
8
|
+
let(:fullpath) { '/products/baseball-cap' }
|
|
9
|
+
let(:session) { {} }
|
|
10
|
+
let(:request) { double(fullpath: fullpath) }
|
|
11
|
+
let(:controller) do
|
|
12
|
+
instance_double(
|
|
13
|
+
ApplicationController,
|
|
14
|
+
request: request,
|
|
15
|
+
session: session,
|
|
16
|
+
controller_name: 'app_controller_double'
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module CustomRule
|
|
21
|
+
def self.match?(_controller)
|
|
22
|
+
true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after :each do
|
|
27
|
+
described_class.rules.delete('CustomRule')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '::rules' do
|
|
31
|
+
it 'includes default rules' do
|
|
32
|
+
rule = Spree::UserLastUrlStorer::Rules::AuthenticationRule
|
|
33
|
+
expect(described_class.rules).to include(rule)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'can add new rules' do
|
|
37
|
+
described_class.rules << CustomRule
|
|
38
|
+
expect(described_class.rules).to include(CustomRule)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#store_location' do
|
|
43
|
+
context 'when at least one rule matches' do
|
|
44
|
+
it 'does not set the path value into the session' do
|
|
45
|
+
described_class.rules << CustomRule
|
|
46
|
+
subject.store_location
|
|
47
|
+
expect(session[:spree_user_return_to]).to be_nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context 'when no rule matches' do
|
|
52
|
+
it 'sets the path value into the session' do
|
|
53
|
+
described_class.rules << CustomRule
|
|
54
|
+
described_class.rules.delete('CustomRule')
|
|
55
|
+
subject.store_location
|
|
56
|
+
expect(session[:spree_user_return_to]).to eql fullpath
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|