solidus_core 2.4.2 → 2.5.0.beta1
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 +5 -5
- data/README.md +1 -5
- data/Rakefile +23 -6
- data/app/helpers/spree/base_helper.rb +15 -10
- data/app/helpers/spree/checkout_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +2 -2
- data/app/mailers/spree/carton_mailer.rb +2 -2
- data/app/mailers/spree/order_mailer.rb +4 -4
- data/app/mailers/spree/reimbursement_mailer.rb +2 -2
- data/app/mailers/spree/test_mailer.rb +1 -1
- data/app/models/concerns/spree/adjustment_source.rb +17 -11
- data/app/models/concerns/spree/calculated_adjustments.rb +2 -2
- data/app/models/spree/ability.rb +1 -1
- data/app/models/spree/address.rb +7 -0
- data/app/models/spree/adjustment.rb +6 -2
- data/app/models/spree/calculator.rb +1 -1
- data/app/models/spree/calculator/flexi_rate.rb +1 -0
- data/app/models/spree/calculator/free_shipping.rb +2 -0
- data/app/models/spree/calculator/percent_on_line_item.rb +6 -6
- data/app/models/spree/calculator/percent_per_item.rb +2 -0
- data/app/models/spree/calculator/returns/default_refund_amount.rb +4 -4
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +1 -0
- data/app/models/spree/calculator/shipping/flat_rate.rb +1 -0
- data/app/models/spree/calculator/shipping/flexi_rate.rb +1 -0
- data/app/models/spree/calculator/shipping/per_item.rb +1 -0
- data/app/models/spree/calculator/shipping/price_sack.rb +1 -0
- data/app/models/spree/classification.rb +1 -1
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/inventory_unit.rb +8 -2
- data/app/models/spree/log_entry.rb +0 -11
- data/app/models/spree/order.rb +31 -16
- data/app/models/spree/order_contents.rb +0 -14
- data/app/models/spree/order_shipping.rb +0 -5
- data/app/models/spree/order_updater.rb +0 -4
- data/app/models/spree/payment.rb +6 -1
- data/app/models/spree/payment/processing.rb +4 -4
- data/app/models/spree/payment_method.rb +8 -3
- data/app/models/spree/payment_method/credit_card.rb +1 -1
- data/app/models/spree/payment_method/store_credit.rb +4 -4
- data/app/models/spree/price.rb +7 -1
- data/app/models/spree/product.rb +34 -6
- data/app/models/spree/product/scopes.rb +2 -2
- data/app/models/spree/promotion.rb +1 -2
- data/app/models/spree/promotion/actions/create_adjustment.rb +3 -2
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +7 -8
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/taxon.rb +25 -24
- data/app/models/spree/promotion_action.rb +7 -1
- data/app/models/spree/promotion_chooser.rb +1 -1
- data/app/models/spree/promotion_code.rb +3 -3
- data/app/models/spree/promotion_handler/coupon.rb +8 -29
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/refund.rb +3 -3
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/return_item.rb +3 -3
- data/app/models/spree/return_item/eligibility_validator/base_validator.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +1 -1
- data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +1 -1
- data/app/models/spree/return_item/eligibility_validator/order_completed.rb +1 -1
- data/app/models/spree/return_item/eligibility_validator/rma_required.rb +1 -1
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +1 -1
- data/app/models/spree/shipment.rb +16 -6
- data/app/models/spree/shipping_method.rb +7 -0
- data/app/models/spree/shipping_rate.rb +6 -6
- data/app/models/spree/shipping_rate_tax.rb +2 -2
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/estimator.rb +9 -1
- data/app/models/spree/stock/inventory_unit_builder.rb +1 -2
- data/app/models/spree/stock/inventory_validator.rb +2 -2
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock/simple_coordinator.rb +2 -2
- data/app/models/spree/stock_item.rb +6 -0
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/store_credit.rb +19 -12
- data/app/models/spree/store_credit_category.rb +1 -1
- data/app/models/spree/store_credit_event.rb +7 -1
- data/app/models/spree/tax/shipping_rate_taxer.rb +1 -1
- data/app/models/spree/tax_calculator/shipping_rate.rb +12 -3
- data/app/models/spree/tax_rate.rb +10 -3
- data/app/models/spree/taxon.rb +14 -4
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/unit_cancel.rb +1 -1
- data/app/models/spree/variant.rb +33 -1
- data/app/models/spree/variant/price_selector.rb +1 -1
- data/app/models/spree/variant/pricing_options.rb +1 -1
- data/app/models/spree/variant/scopes.rb +1 -1
- data/app/models/spree/variant/vat_price_generator.rb +1 -1
- data/app/views/spree/carton_mailer/shipped_email.html.erb +6 -6
- data/app/views/spree/carton_mailer/shipped_email.text.erb +6 -6
- data/app/views/spree/order_mailer/cancel_email.html.erb +5 -5
- data/app/views/spree/order_mailer/cancel_email.text.erb +5 -5
- data/app/views/spree/order_mailer/confirm_email.html.erb +9 -9
- data/app/views/spree/order_mailer/confirm_email.text.erb +9 -9
- data/app/views/spree/order_mailer/inventory_cancellation_email.html.erb +3 -3
- data/app/views/spree/order_mailer/inventory_cancellation_email.text.erb +3 -3
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +1 -1
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +1 -1
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +5 -5
- data/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb +5 -5
- data/app/views/spree/shared/_error_messages.html.erb +2 -2
- data/app/views/spree/test_mailer/test_email.html.erb +2 -2
- data/app/views/spree/test_mailer/test_email.text.erb +2 -2
- data/config/initializers/assets.rb +3 -1
- data/config/locales/en.yml +44 -48
- data/db/default/spree/store_credit.rb +1 -1
- data/db/default/spree/stores.rb +7 -8
- data/db/migrate/20160101010000_solidus_one_four.rb +4 -46
- data/db/migrate/20170317035819_add_lft_and_rgt_indexes_to_taxons.rb +6 -0
- data/db/migrate/20170319191942_remove_order_id_from_inventory_units.rb +28 -0
- data/db/migrate/20170608074534_rename_bogus_gateways.rb +4 -2
- data/db/migrate/20170831201542_remove_default_tax_from_spree_zones.rb +1 -1
- data/lib/generators/spree/custom_user/custom_user_generator.rb +11 -22
- data/lib/generators/spree/install/install_generator.rb +10 -5
- data/lib/spree/app_configuration.rb +103 -5
- data/lib/spree/core.rb +3 -2
- data/lib/spree/core/active_merchant_dependencies.rb +11 -0
- data/lib/spree/core/controller_helpers/auth.rb +3 -1
- data/lib/spree/core/controller_helpers/common.rb +3 -7
- data/lib/spree/core/engine.rb +18 -100
- data/lib/spree/core/environment.rb +3 -3
- data/lib/spree/core/importer/order.rb +0 -1
- data/lib/spree/core/permalinks.rb +9 -15
- data/lib/spree/core/product_filters.rb +5 -3
- data/lib/spree/core/role_configuration.rb +23 -7
- data/lib/spree/core/search/base.rb +16 -13
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/paranoia_deprecations.rb +19 -0
- data/lib/spree/permission_sets.rb +0 -4
- data/lib/spree/permitted_attributes.rb +0 -3
- data/lib/spree/preferences/preferable.rb +70 -34
- data/lib/spree/preferences/preferable_class_methods.rb +22 -0
- data/lib/spree/testing_support/authorization_helpers.rb +2 -0
- data/lib/spree/testing_support/common_rake.rb +0 -1
- data/lib/spree/testing_support/dummy_app.rb +100 -0
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +10 -0
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +10 -0
- data/lib/spree/testing_support/dummy_app/assets/stylesheets/spree/backend/all.css +9 -0
- data/lib/spree/testing_support/dummy_app/assets/stylesheets/spree/frontend/all.css +9 -0
- data/lib/spree/testing_support/dummy_app/database.yml +31 -0
- data/lib/spree/testing_support/dummy_app/migrations.rb +35 -0
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +60 -0
- data/lib/spree/testing_support/dummy_app/views/layouts/application.html.erb +1 -0
- data/lib/spree/testing_support/factories.rb +1 -1
- data/lib/spree/testing_support/factories/address_factory.rb +2 -2
- data/lib/spree/testing_support/factories/adjustment_factory.rb +2 -2
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +1 -1
- data/lib/spree/testing_support/factories/carton_factory.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +1 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +2 -2
- data/lib/spree/testing_support/factories/image_factory.rb +1 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +13 -4
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/option_value_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +5 -1
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_method_factory.rb +1 -1
- data/lib/spree/testing_support/factories/price_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +2 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +1 -2
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +2 -2
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/state_factory.rb +1 -7
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_update_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +1 -2
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -10
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +2 -4
- data/lib/spree/testing_support/flash.rb +2 -2
- data/lib/spree/testing_support/order_walkthrough.rb +9 -9
- data/lib/spree/testing_support/preferences.rb +4 -0
- data/lib/spree/testing_support/sequences.rb +3 -12
- data/solidus_core.gemspec +12 -8
- data/spec/helpers/base_helper_spec.rb +19 -3
- data/spec/helpers/products_helper_spec.rb +1 -1
- data/spec/lib/calculated_adjustments_spec.rb +20 -0
- data/spec/lib/i18n_spec.rb +4 -69
- data/spec/lib/search/base_spec.rb +1 -0
- data/spec/lib/search/variant_spec.rb +4 -4
- data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +6 -6
- data/spec/lib/spree/core/importer/order_spec.rb +2 -2
- data/spec/lib/spree/core/role_configuration_spec.rb +6 -9
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +12 -8
- data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_category_factory_spec.rb +1 -1
- data/spec/mailers/carton_mailer_spec.rb +3 -7
- data/spec/mailers/order_mailer_spec.rb +7 -11
- data/spec/mailers/reimbursement_mailer_spec.rb +1 -5
- data/spec/mailers/test_mailer_spec.rb +0 -4
- data/spec/models/spree/ability_spec.rb +2 -1
- data/spec/models/spree/address_spec.rb +32 -19
- data/spec/models/spree/app_configuration_spec.rb +1 -1
- data/spec/models/spree/calculator/distributed_amount_spec.rb +1 -1
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +8 -10
- data/spec/models/spree/calculator/percent_per_item_spec.rb +4 -4
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +10 -3
- data/spec/models/spree/classification_spec.rb +19 -0
- data/spec/models/spree/credit_card_spec.rb +1 -1
- data/spec/models/spree/customer_return_spec.rb +17 -6
- data/spec/models/spree/distributed_amounts_handler_spec.rb +1 -1
- data/spec/models/spree/exchange_spec.rb +1 -1
- data/spec/models/spree/inventory_unit_spec.rb +3 -7
- data/spec/models/spree/line_item_spec.rb +6 -6
- data/spec/models/spree/option_value_spec.rb +11 -6
- data/spec/models/spree/order/callbacks_spec.rb +2 -2
- data/spec/models/spree/order/checkout_spec.rb +31 -31
- data/spec/models/spree/order/risk_assessment_spec.rb +9 -9
- data/spec/models/spree/order_contents_spec.rb +1 -9
- data/spec/models/spree/order_inventory_spec.rb +2 -2
- data/spec/models/spree/order_mutex_spec.rb +3 -1
- data/spec/models/spree/order_shipping_spec.rb +7 -4
- data/spec/models/spree/order_spec.rb +36 -13
- data/spec/models/spree/order_taxation_spec.rb +7 -7
- data/spec/models/spree/order_updater_spec.rb +6 -4
- data/spec/models/spree/payment/cancellation_spec.rb +1 -1
- data/spec/models/spree/payment_create_spec.rb +2 -2
- data/spec/models/spree/payment_method/store_credit_spec.rb +13 -13
- data/spec/models/spree/payment_spec.rb +23 -4
- data/spec/models/spree/preferences/preferable_spec.rb +44 -0
- data/spec/models/spree/preferences/statically_configurable_spec.rb +1 -0
- data/spec/models/spree/price_spec.rb +6 -4
- data/spec/models/spree/product/scopes_spec.rb +1 -1
- data/spec/models/spree/product_spec.rb +49 -9
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +13 -3
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +146 -134
- data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +6 -6
- data/spec/models/spree/promotion/rules/taxon_spec.rb +14 -14
- data/spec/models/spree/promotion_code_spec.rb +31 -19
- data/spec/models/spree/promotion_handler/coupon_spec.rb +42 -17
- data/spec/models/spree/promotion_handler/shipping_spec.rb +1 -6
- data/spec/models/spree/promotion_spec.rb +14 -14
- data/spec/models/spree/refund_spec.rb +1 -1
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +1 -1
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +1 -1
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +3 -2
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +1 -1
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +2 -2
- data/spec/models/spree/return_item_spec.rb +6 -6
- data/spec/models/spree/shipment_spec.rb +14 -10
- data/spec/models/spree/shipping_manifest_spec.rb +22 -9
- data/spec/models/spree/shipping_method_spec.rb +9 -5
- data/spec/models/spree/stock/availability_spec.rb +16 -2
- data/spec/models/spree/stock/estimator_spec.rb +11 -12
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +0 -4
- data/spec/models/spree/stock/package_spec.rb +3 -2
- data/spec/models/spree/stock/simple_coordinator_spec.rb +1 -24
- data/spec/models/spree/stock_item_spec.rb +6 -6
- data/spec/models/spree/stock_location_spec.rb +16 -3
- data/spec/models/spree/store_credit_spec.rb +12 -6
- data/spec/models/spree/tax/taxation_integration_spec.rb +6 -6
- data/spec/models/spree/tax_calculator/default_spec.rb +7 -7
- data/spec/models/spree/taxon_spec.rb +42 -19
- data/spec/models/spree/variant/vat_price_generator_spec.rb +1 -1
- data/spec/models/spree/variant_spec.rb +69 -11
- data/spec/rails_helper.rb +7 -13
- data/spec/spec_helper.rb +3 -12
- data/spec/support/concerns/default_price.rb +1 -1
- data/spec/support/dummy_ability.rb +2 -0
- metadata +144 -73
- data/Gemfile +0 -3
- data/app/models/spree/order_stock_location.rb +0 -15
- data/app/models/spree/stock_transfer.rb +0 -110
- data/app/models/spree/transfer_item.rb +0 -54
- data/lib/generators/spree/custom_user/templates/initializer.rb.tt +0 -1
- data/lib/spree/permission_sets/restricted_stock_transfer_display.rb +0 -17
- data/lib/spree/permission_sets/restricted_stock_transfer_management.rb +0 -52
- data/lib/spree/permission_sets/stock_transfer_display.rb +0 -10
- data/lib/spree/permission_sets/stock_transfer_management.rb +0 -11
- data/lib/spree/testing_support/factories/stock_transfer_factory.rb +0 -28
- data/lib/spree/testing_support/i18n.rb +0 -97
- data/spec/lib/spree/core/testing_support/factories/stock_transfer_factory_spec.rb +0 -12
- data/spec/models/spree/order_stock_location_spec.rb +0 -18
- data/spec/models/spree/permission_sets/restricted_stock_transfer_display_spec.rb +0 -49
- data/spec/models/spree/permission_sets/restricted_stock_transfer_management_spec.rb +0 -218
- data/spec/models/spree/permission_sets/stock_transfer_display_spec.rb +0 -23
- data/spec/models/spree/permission_sets/stock_transfer_management_spec.rb +0 -23
- data/spec/models/spree/stock_transfer_spec.rb +0 -308
- data/spec/models/spree/transfer_item_spec.rb +0 -275
- data/spec/support/test_gateway.rb +0 -2
|
@@ -26,10 +26,6 @@ module Spree
|
|
|
26
26
|
it "builds the inventory units as pending" do
|
|
27
27
|
expect(subject.units.map(&:pending).uniq).to eq [true]
|
|
28
28
|
end
|
|
29
|
-
|
|
30
|
-
it "associates the inventory units to the order" do
|
|
31
|
-
expect(subject.units.map(&:order).uniq).to eq [order]
|
|
32
|
-
end
|
|
33
29
|
end
|
|
34
30
|
end
|
|
35
31
|
end
|
|
@@ -6,11 +6,12 @@ module Spree
|
|
|
6
6
|
let(:variant) { build(:variant, weight: 25.0) }
|
|
7
7
|
let(:stock_location) { build(:stock_location) }
|
|
8
8
|
let(:order) { build(:order) }
|
|
9
|
+
let(:line_item) { build(:line_item, order: order) }
|
|
9
10
|
|
|
10
11
|
subject { Package.new(stock_location) }
|
|
11
12
|
|
|
12
13
|
def build_inventory_unit
|
|
13
|
-
build(:inventory_unit, variant: variant,
|
|
14
|
+
build(:inventory_unit, variant: variant, line_item: line_item)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
it 'calculates the weight of all the contents' do
|
|
@@ -164,7 +165,7 @@ module Spree
|
|
|
164
165
|
|
|
165
166
|
it "returns an order" do
|
|
166
167
|
expect(subject.order).to be_a_kind_of Spree::Order
|
|
167
|
-
expect(subject.order).to eq
|
|
168
|
+
expect(subject.order).to eq order
|
|
168
169
|
end
|
|
169
170
|
end
|
|
170
171
|
|
|
@@ -109,7 +109,7 @@ module Spree
|
|
|
109
109
|
|
|
110
110
|
context 'with no stock locations' do
|
|
111
111
|
let(:location_1_inventory) { 0 }
|
|
112
|
-
before { variant.stock_items.
|
|
112
|
+
before { variant.stock_items.each(&:really_destroy!) }
|
|
113
113
|
it_behaves_like "an unfulfillable package"
|
|
114
114
|
end
|
|
115
115
|
|
|
@@ -184,29 +184,6 @@ module Spree
|
|
|
184
184
|
let(:location_2_inventory) { 5 }
|
|
185
185
|
it_behaves_like "a fulfillable package"
|
|
186
186
|
end
|
|
187
|
-
|
|
188
|
-
context "with a location configured package" do
|
|
189
|
-
before do
|
|
190
|
-
order.order_stock_locations.create(
|
|
191
|
-
stock_location: stock_location_2,
|
|
192
|
-
quantity: 3,
|
|
193
|
-
variant: variant
|
|
194
|
-
)
|
|
195
|
-
end
|
|
196
|
-
let(:location_quantity) { 3 }
|
|
197
|
-
|
|
198
|
-
context "and sufficient inventory" do
|
|
199
|
-
let(:location_1_inventory) { 5 }
|
|
200
|
-
let(:location_2_inventory) { 5 }
|
|
201
|
-
it_behaves_like "a fulfillable package"
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
context "and insufficient inventory" do
|
|
205
|
-
let(:location_1_inventory) { 0 }
|
|
206
|
-
let(:location_2_inventory) { 3 }
|
|
207
|
-
it_behaves_like "an unfulfillable package"
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
187
|
end
|
|
211
188
|
|
|
212
189
|
context 'with three stock locations' do
|
|
@@ -149,12 +149,12 @@ RSpec.describe Spree::StockItem, type: :model do
|
|
|
149
149
|
before { Spree::StockMovement.create(stock_item: subject, quantity: 1) }
|
|
150
150
|
|
|
151
151
|
it "doesnt raise ReadOnlyRecord error" do
|
|
152
|
-
subject.
|
|
152
|
+
subject.discard
|
|
153
153
|
end
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
context "destroyed" do
|
|
157
|
-
before { subject.
|
|
157
|
+
before { subject.discard }
|
|
158
158
|
|
|
159
159
|
it "recreates stock item just fine" do
|
|
160
160
|
stock_location.stock_items.create!(variant: subject.variant)
|
|
@@ -277,8 +277,8 @@ RSpec.describe Spree::StockItem, type: :model do
|
|
|
277
277
|
|
|
278
278
|
# Regression test for https://github.com/spree/spree/issues/4651
|
|
279
279
|
context "variant" do
|
|
280
|
-
it "can be found even if the variant is deleted" do
|
|
281
|
-
subject.variant.
|
|
280
|
+
it "can be found even if the variant is soft-deleted" do
|
|
281
|
+
subject.variant.discard
|
|
282
282
|
expect(subject.reload.variant).not_to be_nil
|
|
283
283
|
end
|
|
284
284
|
end
|
|
@@ -293,14 +293,14 @@ RSpec.describe Spree::StockItem, type: :model do
|
|
|
293
293
|
shared_examples_for 'valid count_on_hand' do
|
|
294
294
|
it 'has :no errors_on' do
|
|
295
295
|
expect(subject).to be_valid
|
|
296
|
-
expect(subject.
|
|
296
|
+
expect(subject.errors[:count_on_hand].size).to eq(0)
|
|
297
297
|
end
|
|
298
298
|
end
|
|
299
299
|
|
|
300
300
|
shared_examples_for 'invalid count_on_hand' do
|
|
301
301
|
it 'has the correct error on count_on_hand' do
|
|
302
302
|
expect(subject).not_to be_valid
|
|
303
|
-
expect(subject.
|
|
303
|
+
expect(subject.errors[:count_on_hand].size).to eq(1)
|
|
304
304
|
expect(subject.errors[:count_on_hand]).to include('must be greater than or equal to 0')
|
|
305
305
|
end
|
|
306
306
|
end
|
|
@@ -95,7 +95,7 @@ module Spree
|
|
|
95
95
|
describe '#stock_item_or_create' do
|
|
96
96
|
before do
|
|
97
97
|
variant = create(:variant)
|
|
98
|
-
variant.stock_items.
|
|
98
|
+
variant.stock_items.each(&:really_destroy!)
|
|
99
99
|
variant.save
|
|
100
100
|
end
|
|
101
101
|
|
|
@@ -213,7 +213,20 @@ module Spree
|
|
|
213
213
|
|
|
214
214
|
it 'zero on_hand and backordered' do
|
|
215
215
|
subject
|
|
216
|
-
variant.stock_items.
|
|
216
|
+
variant.stock_items.each(&:really_destroy!)
|
|
217
|
+
on_hand, backordered = subject.fill_status(variant, 1)
|
|
218
|
+
expect(on_hand).to eq 0
|
|
219
|
+
expect(backordered).to eq 0
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context 'with soft-deleted stock_items' do
|
|
224
|
+
subject { create(:stock_location) }
|
|
225
|
+
let(:variant) { create(:base_variant) }
|
|
226
|
+
|
|
227
|
+
it 'zero on_hand and backordered' do
|
|
228
|
+
subject
|
|
229
|
+
variant.stock_items.discard_all
|
|
217
230
|
on_hand, backordered = subject.fill_status(variant, 1)
|
|
218
231
|
expect(on_hand).to eq 0
|
|
219
232
|
expect(backordered).to eq 0
|
|
@@ -247,7 +260,7 @@ module Spree
|
|
|
247
260
|
end
|
|
248
261
|
|
|
249
262
|
context "no stock item exists" do
|
|
250
|
-
before { subject.stock_items.
|
|
263
|
+
before { subject.stock_items.each(&:really_destroy!) }
|
|
251
264
|
context "positive movement" do
|
|
252
265
|
let(:quantity) { 1 }
|
|
253
266
|
it "creates a stock item" do
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'rails_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe Spree::StoreCredit do
|
|
4
|
+
include ActiveSupport::Testing::TimeHelpers
|
|
5
|
+
|
|
4
6
|
let(:currency) { "TEST" }
|
|
5
7
|
let(:store_credit) { build(:store_credit, store_credit_attrs) }
|
|
6
8
|
let(:store_credit_attrs) { {} }
|
|
@@ -10,12 +12,16 @@ RSpec.describe Spree::StoreCredit do
|
|
|
10
12
|
|
|
11
13
|
context "amount used is greater than zero" do
|
|
12
14
|
let(:store_credit) { create(:store_credit, amount: 100, amount_used: 1) }
|
|
13
|
-
subject { store_credit.destroy }
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
subject
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
describe "#discard" do
|
|
17
|
+
subject { store_credit.discard }
|
|
18
|
+
|
|
19
|
+
it 'can not delete the store credit' do
|
|
20
|
+
subject
|
|
21
|
+
expect(store_credit.reload).to eq store_credit
|
|
22
|
+
expect(store_credit.errors[:amount_used]).to include("is greater than zero. Can not delete store credit")
|
|
23
|
+
expect(store_credit).not_to be_discarded
|
|
24
|
+
end
|
|
19
25
|
end
|
|
20
26
|
end
|
|
21
27
|
|
|
@@ -839,7 +845,7 @@ RSpec.describe Spree::StoreCredit do
|
|
|
839
845
|
|
|
840
846
|
it "sets the invalidated_at field to the current time" do
|
|
841
847
|
invalidated_at = 2.minutes.from_now
|
|
842
|
-
|
|
848
|
+
travel_to(invalidated_at) do
|
|
843
849
|
subject
|
|
844
850
|
expect(store_credit.invalidated_at).to be_within(1.second).of invalidated_at
|
|
845
851
|
end
|
|
@@ -646,16 +646,16 @@ RSpec.describe "Taxation system integration tests" do
|
|
|
646
646
|
expect(line_item.additional_tax_total).to eq(3)
|
|
647
647
|
end
|
|
648
648
|
|
|
649
|
-
it "should delete adjustments for open order when taxrate is deleted" do
|
|
650
|
-
new_york_books_tax.
|
|
651
|
-
federal_books_tax.
|
|
649
|
+
it "should delete adjustments for open order when taxrate is soft-deleted" do
|
|
650
|
+
new_york_books_tax.discard
|
|
651
|
+
federal_books_tax.discard
|
|
652
652
|
expect(line_item.adjustments.count).to eq(0)
|
|
653
653
|
end
|
|
654
654
|
|
|
655
|
-
it "should not delete adjustments for complete order when taxrate is deleted" do
|
|
655
|
+
it "should not delete adjustments for complete order when taxrate is soft-deleted" do
|
|
656
656
|
order.update_column :completed_at, Time.now
|
|
657
|
-
new_york_books_tax.
|
|
658
|
-
federal_books_tax.
|
|
657
|
+
new_york_books_tax.discard
|
|
658
|
+
federal_books_tax.discard
|
|
659
659
|
expect(line_item.adjustments.count).to eq(2)
|
|
660
660
|
end
|
|
661
661
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'rails_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe Spree::TaxCalculator::Default do
|
|
4
|
-
let(:shipping_address) {
|
|
5
|
-
let(:order) {
|
|
4
|
+
let(:shipping_address) { FactoryBot.create(:address, state: new_york) }
|
|
5
|
+
let(:order) { FactoryBot.create(:order, ship_address: shipping_address, state: "delivery") }
|
|
6
6
|
|
|
7
|
-
let(:new_york) {
|
|
8
|
-
let(:new_york_zone) {
|
|
7
|
+
let(:new_york) { FactoryBot.create(:state, state_code: "NY") }
|
|
8
|
+
let(:new_york_zone) { FactoryBot.create(:zone, states: [new_york]) }
|
|
9
9
|
|
|
10
|
-
let(:books_category) {
|
|
10
|
+
let(:books_category) { FactoryBot.create(:tax_category, name: "Books") }
|
|
11
11
|
let!(:book_tax_rate) do
|
|
12
|
-
|
|
12
|
+
FactoryBot.create(
|
|
13
13
|
:tax_rate,
|
|
14
14
|
name: "New York Sales Tax",
|
|
15
15
|
tax_categories: [books_category],
|
|
@@ -20,7 +20,7 @@ RSpec.describe Spree::TaxCalculator::Default do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
before do
|
|
23
|
-
book =
|
|
23
|
+
book = FactoryBot.create(
|
|
24
24
|
:product,
|
|
25
25
|
price: 20,
|
|
26
26
|
name: "Book",
|
|
@@ -4,28 +4,22 @@ require 'rails_helper'
|
|
|
4
4
|
|
|
5
5
|
RSpec.describe Spree::Taxon, type: :model do
|
|
6
6
|
describe '#to_param' do
|
|
7
|
-
let(:taxon) {
|
|
7
|
+
let(:taxon) { FactoryBot.build(:taxon, name: "Ruby on Rails") }
|
|
8
8
|
|
|
9
9
|
subject { super().to_param }
|
|
10
10
|
it { is_expected.to eql taxon.permalink }
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
context "set_permalink" do
|
|
14
|
-
let(:taxon) {
|
|
14
|
+
let(:taxon) { FactoryBot.build(:taxon, name: "Ruby on Rails") }
|
|
15
15
|
|
|
16
16
|
it "should set permalink correctly when no parent present" do
|
|
17
17
|
taxon.set_permalink
|
|
18
18
|
expect(taxon.permalink).to eql "ruby-on-rails"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it "should support Chinese characters" do
|
|
22
|
-
taxon.name = "你好"
|
|
23
|
-
taxon.set_permalink
|
|
24
|
-
expect(taxon.permalink).to eql 'ni-hao'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
21
|
context "with parent taxon" do
|
|
28
|
-
let(:parent) {
|
|
22
|
+
let(:parent) { FactoryBot.build(:taxon, permalink: "brands") }
|
|
29
23
|
before { allow(taxon).to receive_messages parent: parent }
|
|
30
24
|
|
|
31
25
|
it "should set permalink correctly when taxon has parent" do
|
|
@@ -39,12 +33,6 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
39
33
|
expect(taxon.permalink).to eql "brands/rubyonrails"
|
|
40
34
|
end
|
|
41
35
|
|
|
42
|
-
it "should support Chinese characters" do
|
|
43
|
-
taxon.name = "我"
|
|
44
|
-
taxon.set_permalink
|
|
45
|
-
expect(taxon.permalink).to eql "brands/wo"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
36
|
# Regression test for https://github.com/spree/spree/issues/3390
|
|
49
37
|
context "setting a new node sibling position via :child_index=" do
|
|
50
38
|
let(:idx) { rand(0..100) }
|
|
@@ -80,7 +68,7 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
80
68
|
end
|
|
81
69
|
|
|
82
70
|
it "changes child's permalink" do
|
|
83
|
-
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/
|
|
71
|
+
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/t2_child').to('t/t1/t2/t2_child')
|
|
84
72
|
end
|
|
85
73
|
end
|
|
86
74
|
|
|
@@ -94,7 +82,7 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
94
82
|
end
|
|
95
83
|
|
|
96
84
|
it "changes child's permalink" do
|
|
97
|
-
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/
|
|
85
|
+
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/t2_child').to('t/foo/t2_child')
|
|
98
86
|
end
|
|
99
87
|
end
|
|
100
88
|
|
|
@@ -108,7 +96,7 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
108
96
|
end
|
|
109
97
|
|
|
110
98
|
it "changes child's permalink" do
|
|
111
|
-
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/
|
|
99
|
+
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/t2_child').to('t/foo/t2_child')
|
|
112
100
|
end
|
|
113
101
|
end
|
|
114
102
|
|
|
@@ -122,7 +110,7 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
122
110
|
end
|
|
123
111
|
|
|
124
112
|
it "changes child's permalink" do
|
|
125
|
-
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/
|
|
113
|
+
is_expected.to change{ taxon2_child.reload.permalink }.from('t/t2/t2_child').to('t/t1/foo/t2_child')
|
|
126
114
|
end
|
|
127
115
|
end
|
|
128
116
|
end
|
|
@@ -135,4 +123,39 @@ RSpec.describe Spree::Taxon, type: :model do
|
|
|
135
123
|
taxonomy.root.children.unscoped.where(name: "Some name").first_or_create
|
|
136
124
|
end
|
|
137
125
|
end
|
|
126
|
+
|
|
127
|
+
context 'leaves of the taxon tree' do
|
|
128
|
+
let(:taxonomy) { create(:taxonomy, name: 't') }
|
|
129
|
+
let(:root) { taxonomy.root }
|
|
130
|
+
let(:taxon) { create(:taxon, name: 't1', taxonomy: taxonomy, parent: root) }
|
|
131
|
+
let(:child) { create(:taxon, name: 'child taxon', taxonomy: taxonomy, parent: taxon) }
|
|
132
|
+
let(:grandchild) { create(:taxon, name: 'grandchild taxon', taxonomy: taxonomy, parent: child) }
|
|
133
|
+
let(:product1) { create(:product) }
|
|
134
|
+
let(:product2) { create(:product) }
|
|
135
|
+
let(:product3) { create(:product) }
|
|
136
|
+
before do
|
|
137
|
+
product1.taxons << taxon
|
|
138
|
+
product2.taxons << child
|
|
139
|
+
product3.taxons << grandchild
|
|
140
|
+
taxon.reload
|
|
141
|
+
|
|
142
|
+
[product1, product2, product3].each { |p| 2.times.each { create(:variant, product: p) } }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#all_products' do
|
|
146
|
+
it 'returns all descendant products' do
|
|
147
|
+
products = taxon.all_products
|
|
148
|
+
expect(products.count).to eq(3)
|
|
149
|
+
expect(products).to match_array([product1, product2, product3])
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
describe '#all_variants' do
|
|
154
|
+
it 'returns all descendant variants' do
|
|
155
|
+
variants = taxon.all_variants
|
|
156
|
+
expect(variants.count).to eq(9)
|
|
157
|
+
expect(variants).to match_array([product1, product2, product3].map{ |p| p.variants_including_master }.flatten)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
138
161
|
end
|
|
@@ -35,7 +35,7 @@ RSpec.describe Spree::Variant::VatPriceGenerator do
|
|
|
35
35
|
|
|
36
36
|
# We need to remove the price for FR from the database so it is created in memory, and then run VatPriceGenerator twice to trigger the duplicate price issue.
|
|
37
37
|
it "will not build duplicate prices on multiple runs" do
|
|
38
|
-
variant.prices.where(country_iso: "FR").
|
|
38
|
+
variant.prices.where(country_iso: "FR").each(&:really_destroy!)
|
|
39
39
|
variant.reload
|
|
40
40
|
described_class.new(variant).run
|
|
41
41
|
expect { subject }.not_to change { variant.prices.size }
|
|
@@ -114,7 +114,7 @@ RSpec.describe Spree::Variant, type: :model do
|
|
|
114
114
|
context "product has other variants" do
|
|
115
115
|
describe "option value accessors" do
|
|
116
116
|
before {
|
|
117
|
-
@multi_variant =
|
|
117
|
+
@multi_variant = FactoryBot.create :variant, product: variant.product
|
|
118
118
|
variant.product.reload
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -145,7 +145,7 @@ RSpec.describe Spree::Variant, type: :model do
|
|
|
145
145
|
context "and a variant is soft-deleted" do
|
|
146
146
|
let!(:old_options_text) { variant.options_text }
|
|
147
147
|
|
|
148
|
-
before { variant.
|
|
148
|
+
before { variant.discard }
|
|
149
149
|
|
|
150
150
|
it "still keeps the option values for that variant" do
|
|
151
151
|
expect(variant.reload.options_text).to eq(old_options_text)
|
|
@@ -654,19 +654,43 @@ RSpec.describe Spree::Variant, type: :model do
|
|
|
654
654
|
end
|
|
655
655
|
end
|
|
656
656
|
|
|
657
|
-
describe "
|
|
658
|
-
|
|
657
|
+
describe "#discard" do
|
|
658
|
+
it "discards related associations" do
|
|
659
|
+
variant.images = [create(:image)]
|
|
659
660
|
|
|
660
|
-
|
|
661
|
+
expect(variant.stock_items).not_to be_empty
|
|
662
|
+
expect(variant.prices).not_to be_empty
|
|
663
|
+
expect(variant.currently_valid_prices).not_to be_empty
|
|
661
664
|
|
|
662
|
-
|
|
663
|
-
|
|
665
|
+
variant.discard
|
|
666
|
+
|
|
667
|
+
expect(variant.images).to be_empty
|
|
668
|
+
expect(variant.stock_items).to be_empty
|
|
669
|
+
expect(variant.prices).to be_empty
|
|
670
|
+
expect(variant.currently_valid_prices).to be_empty
|
|
664
671
|
end
|
|
665
672
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
673
|
+
describe 'default_price' do
|
|
674
|
+
let!(:previous_variant_price) { variant.display_price }
|
|
675
|
+
|
|
676
|
+
it "should discard default_price" do
|
|
677
|
+
variant.discard
|
|
678
|
+
variant.reload
|
|
679
|
+
expect(variant.default_price).to be_discarded
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
it "should keep its price if deleted" do
|
|
683
|
+
variant.discard
|
|
684
|
+
variant.reload
|
|
685
|
+
expect(variant.display_price).to eq(previous_variant_price)
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
context 'when loading with pre-fetching of default_price' do
|
|
689
|
+
it 'also keeps the previous price' do
|
|
690
|
+
variant.discard
|
|
691
|
+
reloaded_variant = Spree::Variant.with_deleted.includes(:default_price).find_by(id: variant.id)
|
|
692
|
+
expect(reloaded_variant.display_price).to eq(previous_variant_price)
|
|
693
|
+
end
|
|
670
694
|
end
|
|
671
695
|
end
|
|
672
696
|
end
|
|
@@ -730,6 +754,40 @@ RSpec.describe Spree::Variant, type: :model do
|
|
|
730
754
|
end
|
|
731
755
|
end
|
|
732
756
|
|
|
757
|
+
describe ".suppliable" do
|
|
758
|
+
subject { Spree::Variant.suppliable }
|
|
759
|
+
let!(:in_stock_variant) { create(:variant) }
|
|
760
|
+
let!(:out_of_stock_variant) { create(:variant) }
|
|
761
|
+
let!(:backordered_variant) { create(:variant) }
|
|
762
|
+
let!(:stock_location) { create(:stock_location) }
|
|
763
|
+
|
|
764
|
+
before do
|
|
765
|
+
in_stock_variant.stock_items.update_all(count_on_hand: 10)
|
|
766
|
+
backordered_variant.stock_items.update_all(count_on_hand: 0, backorderable: true)
|
|
767
|
+
out_of_stock_variant.stock_items.update_all(count_on_hand: 0, backorderable: false)
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
it "includes the in stock variant" do
|
|
771
|
+
expect( subject ).to include(in_stock_variant)
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
it "includes out of stock variant" do
|
|
775
|
+
expect( subject ).to include(backordered_variant)
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
it "does not include out of stock variant" do
|
|
779
|
+
expect( subject ).not_to include(out_of_stock_variant)
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
context "inventory levels globally not tracked" do
|
|
783
|
+
before { Spree::Config.track_inventory_levels = false }
|
|
784
|
+
|
|
785
|
+
it "includes all variants" do
|
|
786
|
+
expect( subject ).to include(in_stock_variant, backordered_variant, out_of_stock_variant)
|
|
787
|
+
end
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
|
|
733
791
|
describe "#display_image" do
|
|
734
792
|
subject { variant.display_image }
|
|
735
793
|
|