spree_core 3.2.9 → 3.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/number_as_param.rb +9 -0
- data/app/models/concerns/spree/user_address.rb +4 -2
- data/app/models/concerns/spree/user_methods.rb +2 -3
- data/app/models/spree/ability.rb +1 -2
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/base.rb +2 -0
- data/app/models/spree/calculator.rb +1 -1
- data/app/models/spree/calculator/percent_per_item.rb +4 -3
- data/app/models/spree/calculator/returns/default_refund_amount.rb +16 -14
- data/app/models/spree/country.rb +1 -1
- data/app/models/spree/credit_card.rb +26 -21
- data/app/models/spree/customer_return.rb +2 -2
- data/app/models/spree/exchange.rb +7 -2
- data/app/models/spree/image.rb +1 -1
- data/app/models/spree/inventory_unit.rb +39 -3
- data/app/models/spree/line_item.rb +2 -7
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_type_prototype.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/option_value_variant.rb +3 -0
- data/app/models/spree/order.rb +82 -81
- data/app/models/spree/order/checkout.rb +23 -33
- data/app/models/spree/order/currency_updater.rb +1 -1
- data/app/models/spree/order/payments.rb +1 -1
- data/app/models/spree/order/store_credit.rb +6 -1
- data/app/models/spree/order_contents.rb +14 -2
- data/app/models/spree/order_inventory.rb +64 -60
- data/app/models/spree/payment.rb +8 -13
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/payment_method.rb +4 -2
- data/app/models/spree/preference.rb +1 -1
- data/app/models/spree/preferences/preferable.rb +1 -1
- data/app/models/spree/product.rb +1 -1
- data/app/models/spree/product/scopes.rb +2 -2
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/promotion/rules/option_value.rb +13 -5
- data/app/models/spree/promotion_rule_user.rb +1 -1
- data/app/models/spree/property_prototype.rb +1 -1
- data/app/models/spree/prototype_taxon.rb +1 -1
- data/app/models/spree/refund.rb +2 -2
- data/app/models/spree/reimbursement.rb +2 -1
- data/app/models/spree/reimbursement_type.rb +1 -1
- data/app/models/spree/return_authorization.rb +1 -0
- data/app/models/spree/return_item.rb +35 -9
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/role_user.rb +1 -1
- data/app/models/spree/shipment.rb +63 -64
- data/app/models/spree/shipment_handler.rb +1 -1
- data/app/models/spree/shipping_category.rb +1 -1
- data/app/models/spree/shipping_method.rb +12 -10
- data/app/models/spree/state_change.rb +1 -1
- data/app/models/spree/stock/adjuster.rb +35 -14
- data/app/models/spree/stock/availability_validator.rb +1 -1
- data/app/models/spree/stock/content_item.rb +9 -8
- data/app/models/spree/stock/coordinator.rb +3 -9
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/inventory_unit_builder.rb +10 -9
- data/app/models/spree/stock/package.rb +6 -6
- data/app/models/spree/stock/packer.rb +8 -15
- data/app/models/spree/stock/prioritizer.rb +13 -10
- data/app/models/spree/stock/splitter/weight.rb +62 -10
- data/app/models/spree/stock_item.rb +42 -29
- data/app/models/spree/stock_location.rb +5 -1
- data/app/models/spree/stock_movement.rb +1 -2
- data/app/models/spree/stock_transfer.rb +2 -3
- data/app/models/spree/store.rb +1 -1
- data/app/models/spree/store_credit.rb +9 -6
- data/app/models/spree/store_credit_category.rb +1 -1
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/taxon.rb +5 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/tracker.rb +1 -1
- data/app/models/spree/variant.rb +4 -3
- data/app/models/spree/zone.rb +19 -21
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +61 -0
- data/config/locales/en.yml +7 -6
- data/db/migrate/20130807024301_upgrade_adjustments.rb +6 -0
- data/db/migrate/20130807024302_rename_adjustment_fields.rb +6 -0
- data/db/migrate/20161125065505_add_quantity_to_inventory_units.rb +5 -0
- data/db/migrate/20170119122701_add_original_return_item_id_to_spree_inventory_units.rb +29 -0
- data/db/migrate/20170315152755_add_unique_index_on_number_to_spree_orders.rb +16 -0
- data/db/migrate/20170316154338_add_unique_index_on_number_to_spree_stock_transfer.rb +16 -0
- data/db/migrate/20170316205511_add_unique_index_on_number_to_spree_shipment.rb +16 -0
- data/db/migrate/20170320134043_add_unique_index_on_number_to_spree_payments.rb +17 -0
- data/db/migrate/20170320142750_add_unique_index_on_number_to_spree_return_authorizations.rb +16 -0
- data/db/migrate/20170320145040_add_unique_index_on_number_to_spree_customer_returns.rb +16 -0
- data/db/migrate/20170320145518_add_unique_index_on_number_to_spree_reimbursements.rb +16 -0
- data/db/migrate/20170323151450_add_missing_unique_indexes_for_unique_attributes.rb +37 -0
- data/db/migrate/20170329110859_add_index_on_stock_location_to_spree_customer_returns.rb +5 -0
- data/db/migrate/20170329113917_add_index_on_prototype_to_spree_option_type_prototype.rb +19 -0
- data/db/migrate/20170330082155_add_indexes_to_spree_option_value_variant.rb +19 -0
- data/db/migrate/20170330132215_add_index_on_promotion_id_to_order_promotions.rb +5 -0
- data/db/migrate/20170331101758_add_indexes_for_property_prototype.rb +20 -0
- data/db/migrate/20170331103334_add_index_for_prototype_id_to_prototype_taxons.rb +5 -0
- data/db/migrate/20170331110454_add_indexes_to_refunds.rb +6 -0
- data/db/migrate/20170331111757_add_indexes_to_reimbursement_credits.rb +6 -0
- data/db/migrate/20170331115246_add_indexes_to_return_authorizations.rb +6 -0
- data/db/migrate/20170331120125_add_indexes_to_return_items.rb +11 -0
- data/db/migrate/20170331121725_add_index_to_role_users.rb +18 -0
- data/db/migrate/20170331123625_add_index_to_shipping_method_categories.rb +5 -0
- data/db/migrate/20170331123832_add_index_to_shipping_method_zones.rb +20 -0
- data/db/migrate/20170331124251_add_index_to_spree_shipping_rates.rb +6 -0
- data/db/migrate/20170331124513_add_index_to_spree_stock_items.rb +5 -0
- data/db/migrate/20170331124924_add_index_to_spree_stock_movement.rb +5 -0
- data/db/migrate/20170413211707_change_indexes_on_friendly_id_slugs.rb +10 -0
- data/lib/generators/spree/install/install_generator.rb +41 -36
- data/lib/spree/core.rb +0 -1
- data/lib/spree/core/engine.rb +3 -3
- data/lib/spree/core/importer/order.rb +23 -19
- data/lib/spree/core/number_generator.rb +3 -5
- data/lib/spree/core/product_duplicator.rb +7 -3
- data/lib/spree/core/search/base.rb +1 -0
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +1 -15
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/common_rake.rb +0 -2
- data/lib/spree/testing_support/factories.rb +3 -3
- data/lib/spree/testing_support/factories/address_factory.rb +1 -1
- data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_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 +1 -1
- data/lib/spree/testing_support/factories/image_factory.rb +1 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/options_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +7 -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_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/prototype_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_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/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +2 -1
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_factory.rb +1 -1
- 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/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 +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tag_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +2 -2
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +2 -2
- data/lib/spree/testing_support/factories/tracker_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_member_factory.rb +1 -1
- data/lib/spree/testing_support/microdata.rb +3 -0
- data/lib/spree/testing_support/order_walkthrough.rb +9 -9
- data/lib/tasks/exchanges.rake +8 -10
- data/spec/helpers/base_helper_spec.rb +200 -0
- data/spec/helpers/products_helper_spec.rb +289 -0
- data/spec/lib/calculated_adjustments_spec.rb +7 -0
- data/spec/lib/i18n_spec.rb +123 -0
- data/spec/lib/search/base_spec.rb +86 -0
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +103 -0
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +110 -0
- data/spec/lib/spree/core/controller_helpers/search_spec.rb +17 -0
- data/spec/lib/spree/core/controller_helpers/store_spec.rb +72 -0
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +39 -0
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +22 -0
- data/spec/lib/spree/core/importer/order_spec.rb +607 -0
- data/spec/lib/spree/core/number_generator_spec.rb +139 -0
- data/spec/lib/spree/core/token_generator_spec.rb +24 -0
- data/spec/lib/spree/core/validators/email_spec.rb +54 -0
- data/spec/lib/spree/core_spec.rb +23 -0
- data/spec/lib/spree/localized_number_spec.rb +54 -0
- data/spec/lib/spree/migrations_spec.rb +36 -0
- data/spec/lib/spree/money_spec.rb +122 -0
- data/spec/lib/tasks/exchanges_spec.rb +136 -0
- data/spec/mailers/order_mailer_spec.rb +122 -0
- data/spec/mailers/reimbursement_mailer_spec.rb +52 -0
- data/spec/mailers/shipment_mailer_spec.rb +81 -0
- data/spec/mailers/test_mailer_spec.rb +38 -0
- data/spec/models/spree/ability_spec.rb +251 -0
- data/spec/models/spree/address_spec.rb +402 -0
- data/spec/models/spree/adjustable/adjuster/base_spec.rb +10 -0
- data/spec/models/spree/adjustable/adjuster/promotion_spec.rb +211 -0
- data/spec/models/spree/adjustable/adjuster/tax_spec.rb +86 -0
- data/spec/models/spree/adjustable/adjustments_updater_spec.rb +26 -0
- data/spec/models/spree/adjustment_spec.rb +189 -0
- data/spec/models/spree/app_configuration_spec.rb +26 -0
- data/spec/models/spree/asset_spec.rb +28 -0
- data/spec/models/spree/calculator/default_tax_spec.rb +152 -0
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +25 -0
- data/spec/models/spree/calculator/flat_rate_spec.rb +47 -0
- data/spec/models/spree/calculator/flexi_rate_spec.rb +41 -0
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +15 -0
- data/spec/models/spree/calculator/price_sack_spec.rb +30 -0
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +47 -0
- data/spec/models/spree/calculator/shipping.rb +8 -0
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +23 -0
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +13 -0
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +52 -0
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +20 -0
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +29 -0
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +40 -0
- data/spec/models/spree/calculator/tiered_percent_spec.rb +51 -0
- data/spec/models/spree/calculator_spec.rb +69 -0
- data/spec/models/spree/classification_spec.rb +93 -0
- data/spec/models/spree/concerns/display_money_spec.rb +43 -0
- data/spec/models/spree/concerns/user_methods_spec.rb +82 -0
- data/spec/models/spree/concerns/vat_price_calculation_spec.rb +66 -0
- data/spec/models/spree/country_spec.rb +55 -0
- data/spec/models/spree/credit_card_spec.rb +328 -0
- data/spec/models/spree/customer_return_spec.rb +240 -0
- data/spec/models/spree/exchange_spec.rb +75 -0
- data/spec/models/spree/gateway/bogus_simple.rb +20 -0
- data/spec/models/spree/gateway/bogus_spec.rb +13 -0
- data/spec/models/spree/gateway_spec.rb +61 -0
- data/spec/models/spree/image_spec.rb +8 -0
- data/spec/models/spree/inventory_unit_spec.rb +256 -0
- data/spec/models/spree/line_item_spec.rb +348 -0
- data/spec/models/spree/option_type_prototype_spec.rb +9 -0
- data/spec/models/spree/option_type_spec.rb +14 -0
- data/spec/models/spree/option_value_spec.rb +18 -0
- data/spec/models/spree/order/address_spec.rb +50 -0
- data/spec/models/spree/order/adjustments_spec.rb +29 -0
- data/spec/models/spree/order/callbacks_spec.rb +42 -0
- data/spec/models/spree/order/checkout_spec.rb +770 -0
- data/spec/models/spree/order/currency_updater_spec.rb +32 -0
- data/spec/models/spree/order/finalizing_spec.rb +114 -0
- data/spec/models/spree/order/helpers_spec.rb +5 -0
- data/spec/models/spree/order/payment_spec.rb +214 -0
- data/spec/models/spree/order/risk_assessment_spec.rb +84 -0
- data/spec/models/spree/order/shipments_spec.rb +43 -0
- data/spec/models/spree/order/state_machine_spec.rb +212 -0
- data/spec/models/spree/order/store_credit_spec.rb +457 -0
- data/spec/models/spree/order/tax_spec.rb +84 -0
- data/spec/models/spree/order/totals_spec.rb +24 -0
- data/spec/models/spree/order/updating_spec.rb +18 -0
- data/spec/models/spree/order/validations_spec.rb +15 -0
- data/spec/models/spree/order_contents_spec.rb +332 -0
- data/spec/models/spree/order_inventory_spec.rb +247 -0
- data/spec/models/spree/order_merger_spec.rb +135 -0
- data/spec/models/spree/order_spec.rb +1067 -0
- data/spec/models/spree/order_updater_spec.rb +305 -0
- data/spec/models/spree/payment/gateway_options_spec.rb +127 -0
- data/spec/models/spree/payment/store_credit_spec.rb +60 -0
- data/spec/models/spree/payment_method/store_credit_spec.rb +291 -0
- data/spec/models/spree/payment_method_spec.rb +108 -0
- data/spec/models/spree/payment_spec.rb +922 -0
- data/spec/models/spree/preference_spec.rb +80 -0
- data/spec/models/spree/preferences/configuration_spec.rb +30 -0
- data/spec/models/spree/preferences/preferable_spec.rb +344 -0
- data/spec/models/spree/preferences/scoped_store_spec.rb +58 -0
- data/spec/models/spree/preferences/store_spec.rb +46 -0
- data/spec/models/spree/price_spec.rb +128 -0
- data/spec/models/spree/product/scopes_spec.rb +174 -0
- data/spec/models/spree/product_duplicator_spec.rb +102 -0
- data/spec/models/spree/product_filter_spec.rb +26 -0
- data/spec/models/spree/product_option_type_spec.rb +9 -0
- data/spec/models/spree/product_promotion_rule_spec.rb +9 -0
- data/spec/models/spree/product_property_spec.rb +26 -0
- data/spec/models/spree/product_spec.rb +626 -0
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +113 -0
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +148 -0
- data/spec/models/spree/promotion/actions/create_line_items_spec.rb +86 -0
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +36 -0
- data/spec/models/spree/promotion/rules/country_spec.rb +36 -0
- data/spec/models/spree/promotion/rules/first_order_spec.rb +75 -0
- data/spec/models/spree/promotion/rules/item_total_spec.rb +282 -0
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +42 -0
- data/spec/models/spree/promotion/rules/option_value_spec.rb +90 -0
- data/spec/models/spree/promotion/rules/product_spec.rb +143 -0
- data/spec/models/spree/promotion/rules/taxon_spec.rb +102 -0
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +27 -0
- data/spec/models/spree/promotion/rules/user_spec.rb +45 -0
- data/spec/models/spree/promotion_action_spec.rb +10 -0
- data/spec/models/spree/promotion_category_spec.rb +17 -0
- data/spec/models/spree/promotion_handler/cart_spec.rb +102 -0
- data/spec/models/spree/promotion_handler/coupon_spec.rb +323 -0
- data/spec/models/spree/promotion_handler/free_shipping_spec.rb +48 -0
- data/spec/models/spree/promotion_handler/page_spec.rb +44 -0
- data/spec/models/spree/promotion_rule_spec.rb +29 -0
- data/spec/models/spree/promotion_rule_taxon_spec.rb +9 -0
- data/spec/models/spree/promotion_rule_user_spec.rb +9 -0
- data/spec/models/spree/promotion_spec.rb +674 -0
- data/spec/models/spree/property_prototype_spec.rb +9 -0
- data/spec/models/spree/property_spec.rb +5 -0
- data/spec/models/spree/prototype_spec.rb +5 -0
- data/spec/models/spree/prototype_taxon_spec.rb +9 -0
- data/spec/models/spree/refund_reason_spec.rb +20 -0
- data/spec/models/spree/refund_spec.rb +195 -0
- data/spec/models/spree/reimbursement/credit_spec.rb +36 -0
- data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +140 -0
- data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +83 -0
- data/spec/models/spree/reimbursement_performer_spec.rb +30 -0
- data/spec/models/spree/reimbursement_spec.rb +188 -0
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +63 -0
- data/spec/models/spree/reimbursement_type/credit_spec.rb +53 -0
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +46 -0
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +55 -0
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +101 -0
- data/spec/models/spree/return_authorization_reason_spec.rb +7 -0
- data/spec/models/spree/return_authorization_spec.rb +230 -0
- data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +77 -0
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +58 -0
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +61 -0
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +32 -0
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +29 -0
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +35 -0
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +65 -0
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +43 -0
- data/spec/models/spree/return_item_spec.rb +734 -0
- data/spec/models/spree/returns_calculator_spec.rb +14 -0
- data/spec/models/spree/role_spec.rb +7 -0
- data/spec/models/spree/shipment_spec.rb +744 -0
- data/spec/models/spree/shipping_calculator_spec.rb +45 -0
- data/spec/models/spree/shipping_category_spec.rb +19 -0
- data/spec/models/spree/shipping_method_spec.rb +125 -0
- data/spec/models/spree/shipping_rate_spec.rb +140 -0
- data/spec/models/spree/state_spec.rb +29 -0
- data/spec/models/spree/stock/availability_validator_spec.rb +42 -0
- data/spec/models/spree/stock/content_item_spec.rb +31 -0
- data/spec/models/spree/stock/coordinator_spec.rb +61 -0
- data/spec/models/spree/stock/differentiator_spec.rb +39 -0
- data/spec/models/spree/stock/estimator_spec.rb +202 -0
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +37 -0
- data/spec/models/spree/stock/package_spec.rb +182 -0
- data/spec/models/spree/stock/packer_spec.rb +70 -0
- data/spec/models/spree/stock/prioritizer_spec.rb +125 -0
- data/spec/models/spree/stock/quantifier_spec.rb +126 -0
- data/spec/models/spree/stock/splitter/backordered_spec.rb +29 -0
- data/spec/models/spree/stock/splitter/base_spec.rb +21 -0
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +47 -0
- data/spec/models/spree/stock/splitter/weight_spec.rb +32 -0
- data/spec/models/spree/stock_item_spec.rb +465 -0
- data/spec/models/spree/stock_location_spec.rb +243 -0
- data/spec/models/spree/stock_movement_spec.rb +120 -0
- data/spec/models/spree/stock_transfer_spec.rb +50 -0
- data/spec/models/spree/store_credit_event_spec.rb +101 -0
- data/spec/models/spree/store_credit_spec.rb +798 -0
- data/spec/models/spree/store_spec.rb +78 -0
- data/spec/models/spree/tax_category_spec.rb +32 -0
- data/spec/models/spree/tax_rate_spec.rb +561 -0
- data/spec/models/spree/taxon_spec.rb +93 -0
- data/spec/models/spree/taxonomy_spec.rb +18 -0
- data/spec/models/spree/tracker_spec.rb +21 -0
- data/spec/models/spree/user_spec.rb +203 -0
- data/spec/models/spree/variant_spec.rb +818 -0
- data/spec/models/spree/zone_member_spec.rb +38 -0
- data/spec/models/spree/zone_spec.rb +472 -0
- data/spec/spec_helper.rb +82 -0
- data/spec/support/big_decimal.rb +5 -0
- data/spec/support/concerns/adjustment_source.rb +23 -0
- data/spec/support/concerns/default_price.rb +37 -0
- data/spec/support/rake.rb +13 -0
- data/spec/support/test_gateway.rb +2 -0
- data/spree_core.gemspec +13 -13
- metadata +252 -45
- data/app/models/concerns/spree/user_api_authentication.rb +0 -19
- data/app/models/spree/calculator/free_shipping.rb +0 -23
- data/config/initializers/premailer_rails.rb +0 -3
- data/config/initializers/user_class_extensions.rb +0 -10
- data/spec/fixtures/microdata.html +0 -22
- data/spec/fixtures/microdata_itemref.html +0 -15
- data/spec/fixtures/microdata_no_itemscope.html +0 -20
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
|
15
15
|
# Updates prices of order's line items
|
16
16
|
def update_line_item_currencies!
|
17
|
-
line_items.where(
|
17
|
+
line_items.where.not(currency: currency).each do |line_item|
|
18
18
|
update_line_item_price!(line_item)
|
19
19
|
end
|
20
20
|
end
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class Order < Spree::Base
|
3
3
|
module StoreCredit
|
4
4
|
def add_store_credit_payments
|
5
|
-
payments.store_credits.where(state:
|
5
|
+
payments.store_credits.where(state: :checkout).map(&:invalidate!)
|
6
6
|
|
7
7
|
remaining_total = outstanding_balance
|
8
8
|
|
@@ -18,9 +18,14 @@ module Spree
|
|
18
18
|
create_store_credit_payment(payment_method, credit, amount_to_take)
|
19
19
|
remaining_total -= amount_to_take
|
20
20
|
end
|
21
|
+
payments.store_credits.checkout
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
def remove_store_credit_payments
|
26
|
+
payments.checkout.store_credits.map(&:invalidate!) unless completed?
|
27
|
+
end
|
28
|
+
|
24
29
|
def covered_by_store_credit?
|
25
30
|
return false unless user
|
26
31
|
user.total_available_store_credit >= total
|
@@ -32,6 +32,7 @@ module Spree
|
|
32
32
|
persist_totals
|
33
33
|
PromotionHandler::Cart.new(order).activate
|
34
34
|
order.ensure_updated_shipments
|
35
|
+
order.payments.store_credits.checkout.destroy_all
|
35
36
|
persist_totals
|
36
37
|
true
|
37
38
|
else
|
@@ -42,9 +43,19 @@ module Spree
|
|
42
43
|
private
|
43
44
|
|
44
45
|
def after_add_or_remove(line_item, options = {})
|
46
|
+
order.payments.store_credits.checkout.destroy_all
|
45
47
|
persist_totals
|
46
48
|
shipment = options[:shipment]
|
47
|
-
shipment.present?
|
49
|
+
if shipment.present?
|
50
|
+
# ADMIN END SHIPMENT RATE FIX
|
51
|
+
# refresh shipments to ensure correct shipment amount is calculated when using price sack calculator
|
52
|
+
# for calculating shipment rates.
|
53
|
+
# Currently shipment rate is calculated on previous order total instead of current order total when updating a shipment from admin end.
|
54
|
+
order.refresh_shipment_rates(ShippingMethod::DISPLAY_ON_BACK_END)
|
55
|
+
shipment.update_amounts
|
56
|
+
else
|
57
|
+
order.ensure_updated_shipments
|
58
|
+
end
|
48
59
|
PromotionHandler::Cart.new(order, line_item).activate
|
49
60
|
Adjustable::AdjustmentsUpdater.update(line_item)
|
50
61
|
TaxRate.adjust(order, [line_item]) if options[:line_item_created]
|
@@ -81,7 +92,8 @@ module Spree
|
|
81
92
|
line_item.quantity += quantity.to_i
|
82
93
|
line_item.currency = currency unless currency.nil?
|
83
94
|
else
|
84
|
-
|
95
|
+
options_params = options.is_a?(ActionController::Parameters) ? options : ActionController::Parameters.new(options.to_h)
|
96
|
+
opts = options_params.
|
85
97
|
permit(PermittedAttributes.line_item_attributes).to_h.
|
86
98
|
merge( { currency: order.currency } )
|
87
99
|
|
@@ -19,96 +19,100 @@ module Spree
|
|
19
19
|
# are always unstocked when the order is completed through +shipment.finalize+
|
20
20
|
def verify(shipment = nil)
|
21
21
|
if order.completed? || shipment.present?
|
22
|
-
|
23
|
-
if
|
24
|
-
quantity = line_item.quantity -
|
22
|
+
units_count = inventory_units.reload.sum(&:quantity)
|
23
|
+
if units_count < line_item.quantity
|
24
|
+
quantity = line_item.quantity - units_count
|
25
25
|
|
26
26
|
shipment = determine_target_shipment unless shipment
|
27
27
|
add_to_shipment(shipment, quantity)
|
28
|
-
elsif
|
29
|
-
remove(
|
30
|
-
elsif inventory_units.size > line_item.quantity
|
31
|
-
remove(inventory_units, shipment)
|
28
|
+
elsif (units_count > line_item.quantity) || (units_count == line_item.quantity && !line_item.changed?)
|
29
|
+
remove(units_count, shipment)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
private
|
37
35
|
|
38
|
-
|
39
|
-
|
36
|
+
def remove(units_count, target_shipment = nil)
|
37
|
+
quantity = set_quantity_to_remove(units_count)
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
39
|
+
if target_shipment.present?
|
40
|
+
remove_from_shipment(target_shipment, quantity)
|
41
|
+
else
|
42
|
+
order.shipments.each do |shipment|
|
43
|
+
break if quantity.zero?
|
44
|
+
quantity -= remove_from_shipment(shipment, quantity)
|
48
45
|
end
|
49
46
|
end
|
47
|
+
end
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
49
|
+
def set_quantity_to_remove(units_count)
|
50
|
+
if (units_count - line_item.quantity).zero?
|
51
|
+
line_item.quantity
|
52
|
+
else
|
53
|
+
units_count - line_item.quantity
|
57
54
|
end
|
55
|
+
end
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
shipment ||= order.shipments.detect do |shipment|
|
69
|
-
shipment.ready_or_pending? && variant.stock_location_ids.include?(shipment.stock_location_id)
|
70
|
-
end
|
57
|
+
# Returns either one of the shipment:
|
58
|
+
#
|
59
|
+
# first unshipped that already includes this variant
|
60
|
+
# first unshipped that's leaving from a stock_location that stocks this variant
|
61
|
+
def determine_target_shipment
|
62
|
+
target_shipment = order.shipments.detect do |shipment|
|
63
|
+
shipment.ready_or_pending? && shipment.include?(variant)
|
71
64
|
end
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
66
|
+
target_shipment || order.shipments.detect do |shipment|
|
67
|
+
shipment.ready_or_pending? && variant.stock_location_ids.include?(shipment.stock_location_id)
|
68
|
+
end
|
69
|
+
end
|
76
70
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
quantity.times { shipment.set_up_inventory('on_hand', variant, order, line_item) }
|
81
|
-
end
|
71
|
+
def add_to_shipment(shipment, quantity)
|
72
|
+
if variant.should_track_inventory?
|
73
|
+
on_hand, back_order = shipment.stock_location.fill_status(variant, quantity)
|
82
74
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
75
|
+
on_hand.times { shipment.set_up_inventory('on_hand', variant, order, line_item) }
|
76
|
+
back_order.times { shipment.set_up_inventory('backordered', variant, order, line_item) }
|
77
|
+
else
|
78
|
+
quantity.times { shipment.set_up_inventory('on_hand', variant, order, line_item) }
|
79
|
+
end
|
87
80
|
|
88
|
-
|
81
|
+
# adding to this shipment, and removing from stock_location
|
82
|
+
if order.completed?
|
83
|
+
shipment.stock_location.unstock(variant, quantity, shipment)
|
89
84
|
end
|
90
85
|
|
91
|
-
|
92
|
-
|
86
|
+
quantity
|
87
|
+
end
|
88
|
+
|
89
|
+
def remove_from_shipment(shipment, quantity)
|
90
|
+
return 0 if quantity.zero? || shipment.shipped?
|
93
91
|
|
94
|
-
|
92
|
+
shipment_units = shipment.inventory_units_for_item(line_item, variant).reject(&:shipped?).sort_by(&:state)
|
95
93
|
|
96
|
-
|
94
|
+
removed_quantity = 0
|
97
95
|
|
98
|
-
|
96
|
+
shipment_units.each do |inventory_unit|
|
97
|
+
inventory_unit.quantity.times do
|
99
98
|
break if removed_quantity == quantity
|
100
|
-
inventory_unit.
|
99
|
+
if inventory_unit.quantity > 1
|
100
|
+
inventory_unit.decrement(:quantity)
|
101
|
+
else
|
102
|
+
inventory_unit.destroy
|
103
|
+
end
|
101
104
|
removed_quantity += 1
|
102
105
|
end
|
106
|
+
end
|
103
107
|
|
104
|
-
|
105
|
-
|
106
|
-
# removing this from shipment, and adding to stock_location
|
107
|
-
if order.completed?
|
108
|
-
shipment.stock_location.restock variant, removed_quantity, shipment
|
109
|
-
end
|
108
|
+
shipment.destroy if shipment.inventory_units.sum(:quantity).zero?
|
110
109
|
|
111
|
-
|
110
|
+
# removing this from shipment, and adding to stock_location
|
111
|
+
if order.completed?
|
112
|
+
shipment.stock_location.restock variant, removed_quantity, shipment
|
112
113
|
end
|
114
|
+
|
115
|
+
removed_quantity
|
116
|
+
end
|
113
117
|
end
|
114
118
|
end
|
data/app/models/spree/payment.rb
CHANGED
@@ -2,11 +2,10 @@ module Spree
|
|
2
2
|
class Payment < Spree::Base
|
3
3
|
include Spree::Core::NumberGenerator.new(prefix: 'P', letters: true, length: 7)
|
4
4
|
|
5
|
-
extend FriendlyId
|
6
|
-
friendly_id :number, slug_column: :number, use: :slugged
|
7
|
-
|
8
5
|
include Spree::Payment::Processing
|
9
6
|
|
7
|
+
include NumberAsParam
|
8
|
+
|
10
9
|
NON_RISKY_AVS_CODES = ['B', 'D', 'H', 'J', 'M', 'Q', 'T', 'V', 'X', 'Y'].freeze
|
11
10
|
RISKY_AVS_CODES = ['A', 'C', 'E', 'F', 'G', 'I', 'K', 'L', 'N', 'O', 'P', 'R', 'S', 'U', 'W', 'Z'].freeze
|
12
11
|
INVALID_STATES = %w(failed invalid).freeze
|
@@ -24,6 +23,8 @@ module Spree
|
|
24
23
|
has_many :refunds, inverse_of: :payment
|
25
24
|
|
26
25
|
validates :payment_method, presence: true
|
26
|
+
validates :number, uniqueness: true
|
27
|
+
|
27
28
|
before_validation :validate_source
|
28
29
|
|
29
30
|
after_save :create_payment_profile, if: :profiles_supported?
|
@@ -211,14 +212,6 @@ module Spree
|
|
211
212
|
gateway_error e
|
212
213
|
end
|
213
214
|
|
214
|
-
def invalidate_old_payments
|
215
|
-
unless has_invalid_state?
|
216
|
-
order.payments.with_state('checkout').where("id != ?", self.id).each do |payment|
|
217
|
-
payment.invalidate!
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
215
|
def split_uncaptured_amount
|
223
216
|
if uncaptured_amount > 0
|
224
217
|
order.payments.create!(
|
@@ -265,8 +258,10 @@ module Spree
|
|
265
258
|
end
|
266
259
|
|
267
260
|
def invalidate_old_payments
|
268
|
-
|
269
|
-
|
261
|
+
# invalid payment or store_credit payment shouldn't invalidate other payment types
|
262
|
+
return if has_invalid_state? || store_credit?
|
263
|
+
|
264
|
+
order.payments.with_state('checkout').where.not(id: id).each do |payment|
|
270
265
|
payment.invalidate! unless payment.store_credit?
|
271
266
|
end
|
272
267
|
end
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
# a new pending payment record for the remaining amount to capture later.
|
30
30
|
def capture!(amount = nil)
|
31
31
|
return true if completed?
|
32
|
-
amount ||= money.
|
32
|
+
amount ||= money.money.cents
|
33
33
|
started_processing!
|
34
34
|
protect_from_connection_error do
|
35
35
|
# Standard ActiveMerchant capture usage
|
@@ -115,7 +115,7 @@ module Spree
|
|
115
115
|
|
116
116
|
def gateway_action(source, action, success_state)
|
117
117
|
protect_from_connection_error do
|
118
|
-
response = payment_method.send(action, money.
|
118
|
+
response = payment_method.send(action, money.money.cents,
|
119
119
|
source,
|
120
120
|
gateway_options)
|
121
121
|
handle_response(response, success_state, :failure)
|
@@ -12,8 +12,10 @@ module Spree
|
|
12
12
|
|
13
13
|
validates :name, presence: true
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
with_options dependent: :restrict_with_error do
|
16
|
+
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
17
|
+
has_many :credit_cards, class_name: "Spree::CreditCard"
|
18
|
+
end
|
17
19
|
|
18
20
|
def self.providers
|
19
21
|
Rails.application.config.spree.payment_methods
|
data/app/models/spree/product.rb
CHANGED
@@ -197,7 +197,7 @@ module Spree
|
|
197
197
|
# Can't use add_search_scope for this as it needs a default argument
|
198
198
|
def self.available(available_on = nil, currency = nil)
|
199
199
|
available_on ||= Time.current
|
200
|
-
not_discontinued.joins(master: :prices).where("#{Product.quoted_table_name}.available_on <= ?", available_on)
|
200
|
+
not_discontinued.joins(master: :prices).where("#{Product.quoted_table_name}.available_on <= ?", available_on)
|
201
201
|
end
|
202
202
|
search_scopes << :available
|
203
203
|
|
@@ -244,7 +244,7 @@ module Spree
|
|
244
244
|
# specifically avoid having an order for taxon search (conflicts with main order)
|
245
245
|
def self.prepare_taxon_conditions(taxons)
|
246
246
|
ids = taxons.map { |taxon| taxon.self_and_descendants.pluck(:id) }.flatten.uniq
|
247
|
-
joins(:
|
247
|
+
joins(:classifications).where(Classification.table_name => { taxon_id: ids })
|
248
248
|
end
|
249
249
|
|
250
250
|
# Produce an array of keywords for use in scopes.
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
|
6
6
|
attr_reader :eligibility_errors
|
7
7
|
|
8
|
-
belongs_to :promotion_category
|
8
|
+
belongs_to :promotion_category, optional: true
|
9
9
|
|
10
10
|
has_many :promotion_rules, autosave: true, dependent: :destroy
|
11
11
|
alias_method :rules, :promotion_rules
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
validates_associated :rules
|
22
22
|
|
23
23
|
validates :name, presence: true
|
24
|
-
validates :path, uniqueness: { allow_blank: true }
|
24
|
+
validates :path, :code, uniqueness: { case_sensitive: false, allow_blank: true }
|
25
25
|
validates :usage_limit, numericality: { greater_than: 0, allow_nil: true }
|
26
26
|
validates :description, length: { maximum: 255 }, allow_blank: true
|
27
27
|
validate :expires_at_must_be_later_than_starts_at, if: -> { starts_at && expires_at }
|
@@ -31,12 +31,20 @@ module Spree
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def actionable?(line_item)
|
34
|
-
|
35
|
-
|
36
|
-
eligible_product_ids = preferred_eligible_values.keys
|
37
|
-
eligible_value_ids = preferred_eligible_values[product_id]
|
34
|
+
pid = line_item.product.id
|
35
|
+
ovids = line_item.variant.option_values.pluck(:id)
|
38
36
|
|
39
|
-
|
37
|
+
product_ids.include?(pid) && (value_ids(pid) - ovids).empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def product_ids
|
43
|
+
preferred_eligible_values.keys
|
44
|
+
end
|
45
|
+
|
46
|
+
def value_ids(product_id)
|
47
|
+
preferred_eligible_values[product_id]
|
40
48
|
end
|
41
49
|
end
|
42
50
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class PromotionRuleUser < Spree::Base
|
3
3
|
belongs_to :promotion_rule, class_name: 'Spree::PromotionRule'
|
4
|
-
belongs_to :user, class_name: Spree.user_class
|
4
|
+
belongs_to :user, class_name: Spree.user_class.to_s
|
5
5
|
|
6
6
|
validates :user, :promotion_rule, presence: true
|
7
7
|
validates :user_id, uniqueness: { scope: :promotion_rule_id }, allow_nil: true
|
@@ -4,6 +4,6 @@ module Spree
|
|
4
4
|
belongs_to :property, class_name: 'Spree::Property'
|
5
5
|
|
6
6
|
validates :prototype, :property, presence: true
|
7
|
-
validates :prototype_id, uniqueness: { scope: :property_id }
|
7
|
+
validates :prototype_id, uniqueness: { scope: :property_id }
|
8
8
|
end
|
9
9
|
end
|