solidus_core 1.0.7 → 1.1.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 +4 -4
- data/app/controllers/spree/base_controller.rb +1 -2
- data/app/helpers/spree/base_helper.rb +4 -5
- data/app/helpers/spree/products_helper.rb +0 -8
- data/app/mailers/spree/carton_mailer.rb +17 -5
- data/app/mailers/spree/order_mailer.rb +12 -4
- data/app/models/concerns/spree/adjustment_source.rb +7 -8
- data/app/models/concerns/spree/default_price.rb +8 -2
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/ordered_property_value_list.rb +28 -0
- data/app/models/concerns/spree/user_address_book.rb +125 -0
- data/app/models/concerns/spree/user_api_authentication.rb +6 -2
- data/app/models/concerns/spree/user_methods.rb +5 -6
- data/app/models/spree/ability.rb +1 -38
- data/app/models/spree/address.rb +79 -36
- data/app/models/spree/adjustment.rb +74 -25
- data/app/models/spree/adjustment_reason.rb +1 -1
- data/app/models/spree/app_configuration.rb +35 -0
- data/app/models/spree/carton.rb +3 -3
- data/app/models/spree/country.rb +7 -1
- data/app/models/spree/credit_card.rb +5 -1
- data/app/models/spree/gateway.rb +0 -8
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/item_adjustments.rb +1 -1
- data/app/models/spree/line_item_action.rb +1 -1
- data/app/models/spree/option_type.rb +3 -2
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/option_values_variant.rb +1 -1
- data/app/models/spree/order.rb +28 -56
- data/app/models/spree/order/checkout.rb +18 -20
- data/app/models/spree/order_mutex.rb +1 -1
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_shipping.rb +6 -12
- data/app/models/spree/order_stock_location.rb +1 -1
- data/app/models/spree/payment.rb +3 -14
- data/app/models/spree/payment/processing.rb +7 -14
- data/app/models/spree/payment_method.rb +5 -5
- data/app/models/spree/permission_sets/default_customer.rb +31 -0
- data/app/models/spree/permission_sets/order_display.rb +4 -0
- data/app/models/spree/permission_sets/order_management.rb +3 -0
- data/app/models/spree/permission_sets/promotion_display.rb +2 -1
- data/app/models/spree/permission_sets/restricted_stock_display.rb +16 -0
- data/app/models/spree/permission_sets/restricted_stock_management.rb +16 -0
- data/app/models/spree/permission_sets/restricted_stock_transfer_display.rb +17 -0
- data/app/models/spree/permission_sets/restricted_stock_transfer_management.rb +51 -0
- data/app/models/spree/permission_sets/stock_display.rb +1 -1
- data/app/models/spree/permission_sets/stock_management.rb +1 -2
- data/app/models/spree/permission_sets/stock_transfer_display.rb +10 -0
- data/app/models/spree/permission_sets/stock_transfer_management.rb +11 -0
- data/app/models/spree/permission_sets/super_user.rb +9 -0
- data/app/models/spree/product.rb +66 -28
- data/app/models/spree/product/scopes.rb +7 -22
- data/app/models/spree/product_option_type.rb +1 -1
- data/app/models/spree/product_promotion_rule.rb +6 -0
- data/app/models/spree/product_property.rb +2 -20
- data/app/models/spree/promotion/rules/product.rb +2 -1
- data/app/models/spree/refund.rb +0 -10
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/return_item.rb +5 -3
- data/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb +13 -4
- data/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb +2 -2
- data/app/models/spree/return_reason.rb +1 -1
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/role_user.rb +1 -1
- data/app/models/spree/shipment.rb +13 -4
- data/app/models/spree/shipping_manifest.rb +9 -3
- data/app/models/spree/shipping_method.rb +2 -3
- data/app/models/spree/shipping_method_zone.rb +6 -0
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/stock_item.rb +15 -3
- data/app/models/spree/stock_movement.rb +1 -1
- data/app/models/spree/store.rb +3 -0
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/store_credit_category.rb +1 -1
- data/app/models/spree/store_credit_event.rb +1 -1
- data/app/models/spree/store_credit_type.rb +1 -1
- data/app/models/spree/store_credit_update_reason.rb +1 -1
- data/app/models/spree/store_payment_method.rb +6 -0
- data/app/models/spree/tax_rate.rb +3 -10
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/transfer_item.rb +1 -1
- data/app/models/spree/unit_cancel.rb +2 -2
- data/app/models/spree/user_address.rb +21 -0
- data/app/models/spree/user_stock_location.rb +1 -1
- data/app/models/spree/variant.rb +28 -13
- data/app/models/spree/variant_property_rule.rb +42 -0
- data/app/models/spree/variant_property_rule_condition.rb +8 -0
- data/app/models/spree/variant_property_rule_value.rb +8 -0
- data/app/models/spree/zone.rb +4 -2
- data/app/views/spree/carton_mailer/shipped_email.text.erb +1 -1
- data/config/locales/en.yml +13 -0
- data/db/default/spree/store_credit.rb +0 -1
- data/db/default/spree/zones.rb +1 -1
- data/db/migrate/20130228210442_create_shipping_method_zone.rb +1 -1
- data/db/migrate/20150121022521_remove_environment_from_payment_method.rb +6 -0
- data/db/migrate/20150506181611_create_spree_store_credit_payment_method.rb +9 -5
- data/db/migrate/20150731201146_add_spree_user_addresses.rb +16 -0
- data/db/migrate/20150811210350_remove_mandatory_from_adjustments.rb +5 -0
- data/db/migrate/20150811211025_add_finalized_to_spree_adjustments.rb +11 -0
- data/db/migrate/20150820160821_add_store_payment_methods.rb +10 -0
- data/db/migrate/20150824213633_convert_habtm_to_hmt_for_shipping_methods_zones.rb +17 -0
- data/db/migrate/20150824214129_convert_habtm_to_hmt_for_products_promotion_rules.rb +17 -0
- data/db/migrate/20150825204216_drop_spree_gateways.rb +20 -0
- data/db/migrate/20150909123605_create_variant_properties_and_rules.rb +28 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +4 -3
- data/lib/spree/core.rb +4 -0
- data/lib/spree/core/controller_helpers/payment_parameters.rb +67 -0
- data/lib/spree/core/delegate_belongs_to.rb +1 -0
- data/lib/spree/core/engine.rb +9 -1
- data/lib/spree/core/importer/order.rb +1 -1
- data/lib/spree/core/role_configuration.rb +1 -1
- data/lib/spree/core/search/variant.rb +20 -2
- data/lib/spree/core/unreturned_item_charger.rb +21 -16
- data/lib/spree/i18n.rb +6 -24
- data/lib/spree/mailer_previews/carton_preview.rb +10 -0
- data/lib/spree/mailer_previews/order_preview.rb +18 -0
- data/lib/spree/permitted_attributes.rb +4 -1
- data/lib/spree/testing_support/capybara_ext.rb +2 -1
- data/lib/spree/testing_support/factories/address_factory.rb +9 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -0
- data/lib/spree/testing_support/factories/image_factory.rb +5 -0
- data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -8
- data/lib/spree/testing_support/factories/user_factory.rb +8 -2
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +6 -0
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +16 -0
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +6 -0
- data/lib/tasks/migrations/migrate_user_addresses.rake +29 -0
- data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +498 -0
- metadata +40 -238
- data/CHANGELOG.md +0 -1
- data/Gemfile +0 -3
- data/Rakefile +0 -16
- data/app/models/concerns/spree/user_address.rb +0 -30
- data/app/models/spree/permission_sets/restricted_transfer_management.rb +0 -35
- data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +0 -19
- data/lib/spree/i18n/base.rb +0 -17
- data/lib/spree/i18n/initializer.rb +0 -1
- data/lib/spree/testing_support/mail.rb +0 -20
- data/script/rails +0 -9
- data/solidus_core.gemspec +0 -48
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/helpers/base_helper_spec.rb +0 -173
- data/spec/helpers/order_helper_spec.rb +0 -12
- data/spec/helpers/products_helper_spec.rb +0 -220
- data/spec/helpers/taxons_helper_spec.rb +0 -17
- data/spec/lib/calculated_adjustments_spec.rb +0 -7
- data/spec/lib/i18n_spec.rb +0 -123
- data/spec/lib/search/base_spec.rb +0 -86
- data/spec/lib/search/variant_spec.rb +0 -92
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +0 -66
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +0 -92
- data/spec/lib/spree/core/controller_helpers/search_spec.rb +0 -17
- data/spec/lib/spree/core/controller_helpers/store_spec.rb +0 -16
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +0 -39
- data/spec/lib/spree/core/current_store_spec.rb +0 -36
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -22
- data/spec/lib/spree/core/importer/order_spec.rb +0 -431
- data/spec/lib/spree/core/role_configuration_spec.rb +0 -138
- data/spec/lib/spree/core/validators/email_spec.rb +0 -48
- data/spec/lib/spree/localized_number_spec.rb +0 -38
- data/spec/lib/spree/migrations_spec.rb +0 -36
- data/spec/lib/spree/money_spec.rb +0 -127
- data/spec/lib/tasks/exchanges_spec.rb +0 -231
- data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +0 -115
- data/spec/lib/tasks/order_capturing_spec.rb +0 -56
- data/spec/mailers/carton_mailer_spec.rb +0 -43
- data/spec/mailers/order_mailer_spec.rb +0 -122
- data/spec/mailers/reimbursement_mailer_spec.rb +0 -40
- data/spec/mailers/test_mailer_spec.rb +0 -15
- data/spec/models/spree/ability_spec.rb +0 -276
- data/spec/models/spree/address_spec.rb +0 -250
- data/spec/models/spree/adjustment_reason_spec.rb +0 -13
- data/spec/models/spree/adjustment_spec.rb +0 -177
- data/spec/models/spree/app_configuration_spec.rb +0 -20
- data/spec/models/spree/asset_spec.rb +0 -24
- data/spec/models/spree/calculator/default_tax_spec.rb +0 -127
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +0 -25
- data/spec/models/spree/calculator/flat_rate_spec.rb +0 -47
- data/spec/models/spree/calculator/flexi_rate_spec.rb +0 -41
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +0 -15
- data/spec/models/spree/calculator/price_sack_spec.rb +0 -30
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +0 -51
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +0 -23
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +0 -13
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +0 -52
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +0 -20
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +0 -30
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +0 -36
- data/spec/models/spree/calculator/tiered_percent_spec.rb +0 -47
- data/spec/models/spree/calculator_spec.rb +0 -36
- data/spec/models/spree/carton_spec.rb +0 -133
- data/spec/models/spree/classification_spec.rb +0 -15
- data/spec/models/spree/concerns/display_money_spec.rb +0 -43
- data/spec/models/spree/concerns/user_methods_spec.rb +0 -41
- data/spec/models/spree/credit_card_spec.rb +0 -334
- data/spec/models/spree/customer_return_spec.rb +0 -276
- data/spec/models/spree/exchange_spec.rb +0 -79
- data/spec/models/spree/gateway/bogus_simple.rb +0 -20
- data/spec/models/spree/gateway/bogus_spec.rb +0 -13
- data/spec/models/spree/gateway_spec.rb +0 -82
- data/spec/models/spree/inventory_unit_spec.rb +0 -307
- data/spec/models/spree/item_adjustments_spec.rb +0 -256
- data/spec/models/spree/line_item_spec.rb +0 -191
- data/spec/models/spree/option_type_spec.rb +0 -14
- data/spec/models/spree/option_value_spec.rb +0 -22
- data/spec/models/spree/order/address_spec.rb +0 -50
- data/spec/models/spree/order/adjustments_spec.rb +0 -39
- data/spec/models/spree/order/callbacks_spec.rb +0 -42
- data/spec/models/spree/order/checkout_spec.rb +0 -902
- data/spec/models/spree/order/currency_updater_spec.rb +0 -32
- data/spec/models/spree/order/finalizing_spec.rb +0 -111
- data/spec/models/spree/order/payment_spec.rb +0 -210
- data/spec/models/spree/order/risk_assessment_spec.rb +0 -68
- data/spec/models/spree/order/state_machine_spec.rb +0 -221
- data/spec/models/spree/order/tax_spec.rb +0 -84
- data/spec/models/spree/order/totals_spec.rb +0 -24
- data/spec/models/spree/order/updating_spec.rb +0 -18
- data/spec/models/spree/order/validations_spec.rb +0 -15
- data/spec/models/spree/order_cancellations_spec.rb +0 -120
- data/spec/models/spree/order_capturing_spec.rb +0 -116
- data/spec/models/spree/order_contents_spec.rb +0 -265
- data/spec/models/spree/order_inventory_spec.rb +0 -228
- data/spec/models/spree/order_mutex_spec.rb +0 -85
- data/spec/models/spree/order_promotion_spec.rb +0 -31
- data/spec/models/spree/order_shipping_spec.rb +0 -247
- data/spec/models/spree/order_spec.rb +0 -1464
- data/spec/models/spree/order_stock_location_spec.rb +0 -18
- data/spec/models/spree/order_updater_spec.rb +0 -299
- data/spec/models/spree/payment_method/store_credit_spec.rb +0 -294
- data/spec/models/spree/payment_method_spec.rb +0 -96
- data/spec/models/spree/payment_spec.rb +0 -1045
- data/spec/models/spree/permission_sets/base_spec.rb +0 -12
- data/spec/models/spree/permission_sets/configuration_display.rb +0 -82
- data/spec/models/spree/permission_sets/configuration_management_spec.rb +0 -50
- data/spec/models/spree/permission_sets/dashboard_display_spec.rb +0 -22
- data/spec/models/spree/permission_sets/order_display_spec.rb +0 -49
- data/spec/models/spree/permission_sets/order_management_spec.rb +0 -36
- data/spec/models/spree/permission_sets/product_display_spec.rb +0 -60
- data/spec/models/spree/permission_sets/product_management_spec.rb +0 -40
- data/spec/models/spree/permission_sets/promotion_display_spec.rb +0 -34
- data/spec/models/spree/permission_sets/promotion_management_spec.rb +0 -26
- data/spec/models/spree/permission_sets/report_display_spec.rb +0 -24
- data/spec/models/spree/permission_sets/restricted_transfer_management_spec.rb +0 -132
- data/spec/models/spree/permission_sets/stock_display_spec.rb +0 -26
- data/spec/models/spree/permission_sets/stock_management_spec.rb +0 -24
- data/spec/models/spree/permission_sets/user_display_spec.rb +0 -36
- data/spec/models/spree/permission_sets/user_management_spec.rb +0 -28
- data/spec/models/spree/preference_spec.rb +0 -80
- data/spec/models/spree/preferences/configuration_spec.rb +0 -30
- data/spec/models/spree/preferences/preferable_spec.rb +0 -294
- data/spec/models/spree/preferences/scoped_store_spec.rb +0 -58
- data/spec/models/spree/preferences/static_model_preferences_spec.rb +0 -78
- data/spec/models/spree/preferences/statically_configurable_spec.rb +0 -60
- data/spec/models/spree/preferences/store_spec.rb +0 -39
- data/spec/models/spree/price_spec.rb +0 -42
- data/spec/models/spree/product/scopes_spec.rb +0 -148
- data/spec/models/spree/product_duplicator_spec.rb +0 -103
- data/spec/models/spree/product_filter_spec.rb +0 -26
- data/spec/models/spree/product_property_spec.rb +0 -20
- data/spec/models/spree/product_spec.rb +0 -437
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +0 -96
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +0 -165
- data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +0 -115
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +0 -40
- data/spec/models/spree/promotion/rules/first_order_spec.rb +0 -75
- data/spec/models/spree/promotion/rules/item_total_spec.rb +0 -67
- data/spec/models/spree/promotion/rules/nth_order_spec.rb +0 -70
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +0 -42
- data/spec/models/spree/promotion/rules/option_value_spec.rb +0 -94
- data/spec/models/spree/promotion/rules/product_spec.rb +0 -143
- data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -102
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +0 -27
- data/spec/models/spree/promotion/rules/user_spec.rb +0 -37
- data/spec/models/spree/promotion_builder_spec.rb +0 -118
- data/spec/models/spree/promotion_category_spec.rb +0 -17
- data/spec/models/spree/promotion_code/code_builder_spec.rb +0 -79
- data/spec/models/spree/promotion_code_spec.rb +0 -187
- data/spec/models/spree/promotion_handler/cart_spec.rb +0 -114
- data/spec/models/spree/promotion_handler/coupon_spec.rb +0 -335
- data/spec/models/spree/promotion_handler/free_shipping_spec.rb +0 -47
- data/spec/models/spree/promotion_handler/page_spec.rb +0 -44
- data/spec/models/spree/promotion_rule_spec.rb +0 -28
- data/spec/models/spree/promotion_spec.rb +0 -767
- data/spec/models/spree/refund_spec.rb +0 -204
- data/spec/models/spree/reimbursement/credit_spec.rb +0 -36
- data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +0 -140
- data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +0 -83
- data/spec/models/spree/reimbursement_performer_spec.rb +0 -30
- data/spec/models/spree/reimbursement_spec.rb +0 -231
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +0 -51
- data/spec/models/spree/reimbursement_type/credit_spec.rb +0 -53
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +0 -46
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +0 -107
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +0 -97
- data/spec/models/spree/return_authorization_spec.rb +0 -290
- data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +0 -77
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +0 -58
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +0 -85
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +0 -32
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +0 -29
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +0 -35
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +0 -65
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +0 -43
- data/spec/models/spree/return_item_spec.rb +0 -775
- data/spec/models/spree/returns_calculator_spec.rb +0 -14
- data/spec/models/spree/shipment_spec.rb +0 -709
- data/spec/models/spree/shipping_calculator_spec.rb +0 -45
- data/spec/models/spree/shipping_method_spec.rb +0 -88
- data/spec/models/spree/shipping_rate_spec.rb +0 -142
- data/spec/models/spree/state_spec.rb +0 -14
- data/spec/models/spree/stock/availability_validator_spec.rb +0 -83
- data/spec/models/spree/stock/coordinator_spec.rb +0 -116
- data/spec/models/spree/stock/differentiator_spec.rb +0 -39
- data/spec/models/spree/stock/estimator_spec.rb +0 -146
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +0 -38
- data/spec/models/spree/stock/package_spec.rb +0 -163
- data/spec/models/spree/stock/packer_spec.rb +0 -91
- data/spec/models/spree/stock/prioritizer_spec.rb +0 -125
- data/spec/models/spree/stock/quantifier_spec.rb +0 -115
- data/spec/models/spree/stock/splitter/backordered_spec.rb +0 -29
- data/spec/models/spree/stock/splitter/base_spec.rb +0 -21
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +0 -50
- data/spec/models/spree/stock/splitter/weight_spec.rb +0 -29
- data/spec/models/spree/stock_item_spec.rb +0 -426
- data/spec/models/spree/stock_location_spec.rb +0 -279
- data/spec/models/spree/stock_movement_spec.rb +0 -56
- data/spec/models/spree/stock_transfer_spec.rb +0 -290
- data/spec/models/spree/store_credit_category_spec.rb +0 -17
- data/spec/models/spree/store_credit_event_spec.rb +0 -314
- data/spec/models/spree/store_credit_spec.rb +0 -876
- data/spec/models/spree/store_spec.rb +0 -55
- data/spec/models/spree/tax_category_spec.rb +0 -27
- data/spec/models/spree/tax_rate_spec.rb +0 -378
- data/spec/models/spree/taxon_spec.rb +0 -74
- data/spec/models/spree/taxonomy_spec.rb +0 -18
- data/spec/models/spree/tracker_spec.rb +0 -21
- data/spec/models/spree/transfer_item_spec.rb +0 -264
- data/spec/models/spree/unit_cancel_spec.rb +0 -148
- data/spec/models/spree/user_spec.rb +0 -223
- data/spec/models/spree/validations/db_maximum_length_validator_spec.rb +0 -23
- data/spec/models/spree/variant/scopes_spec.rb +0 -55
- data/spec/models/spree/variant_spec.rb +0 -546
- data/spec/models/spree/zone_spec.rb +0 -305
- data/spec/spec_helper.rb +0 -78
- data/spec/support/big_decimal.rb +0 -5
- data/spec/support/concerns/default_price.rb +0 -34
- data/spec/support/dummy_ability.rb +0 -4
- data/spec/support/test_gateway.rb +0 -2
|
@@ -4,12 +4,12 @@ module Spree
|
|
|
4
4
|
DISPLAY = [:both, :front_end, :back_end]
|
|
5
5
|
default_scope -> { where(deleted_at: nil) }
|
|
6
6
|
|
|
7
|
-
scope :production, -> { where(environment: 'production') }
|
|
8
|
-
|
|
9
7
|
validates :name, presence: true
|
|
10
8
|
|
|
11
9
|
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
|
12
10
|
has_many :credit_cards, class_name: "Spree::CreditCard"
|
|
11
|
+
has_many :store_payment_methods, inverse_of: :payment_method
|
|
12
|
+
has_many :payment_methods, through: :store_payment_methods
|
|
13
13
|
|
|
14
14
|
include Spree::Preferences::StaticallyConfigurable
|
|
15
15
|
|
|
@@ -28,16 +28,16 @@ module Spree
|
|
|
28
28
|
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def self.available(display_on = 'both')
|
|
31
|
+
def self.available(display_on = 'both', store: nil)
|
|
32
32
|
all.select do |p|
|
|
33
33
|
p.active &&
|
|
34
34
|
(p.display_on == display_on.to_s || p.display_on.blank?) &&
|
|
35
|
-
(
|
|
35
|
+
(store.nil? || store.payment_methods.empty? || store.payment_methods.include?(p))
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def self.active?
|
|
40
|
-
where(type: self.to_s,
|
|
40
|
+
where(type: self.to_s, active: true).count > 0
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def method_type
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PermissionSets
|
|
3
|
+
class DefaultCustomer < PermissionSets::Base
|
|
4
|
+
def activate!
|
|
5
|
+
can :display, Country
|
|
6
|
+
can :display, OptionType
|
|
7
|
+
can :display, OptionValue
|
|
8
|
+
can :create, Order
|
|
9
|
+
can [:read, :update], Order do |order, token|
|
|
10
|
+
order.user == user || order.guest_token && token == order.guest_token
|
|
11
|
+
end
|
|
12
|
+
can :create, ReturnAuthorization do |return_authorization|
|
|
13
|
+
return_authorization.order.user == user
|
|
14
|
+
end
|
|
15
|
+
can [:display, :update], CreditCard, user_id: user.id
|
|
16
|
+
can :display, Product
|
|
17
|
+
can :display, ProductProperty
|
|
18
|
+
can :display, Property
|
|
19
|
+
can :create, Spree.user_class
|
|
20
|
+
can [:read, :update], Spree.user_class, id: user.id
|
|
21
|
+
can :display, State
|
|
22
|
+
can :display, StockItem, stock_location: { active: true }
|
|
23
|
+
can :display, StockLocation, active: true
|
|
24
|
+
can :display, Taxon
|
|
25
|
+
can :display, Taxonomy
|
|
26
|
+
can [:display, :view_out_of_stock], Variant
|
|
27
|
+
can :display, Zone
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -9,6 +9,10 @@ module Spree
|
|
|
9
9
|
can [:display, :admin], Spree::LineItem
|
|
10
10
|
can [:display, :admin], Spree::ReturnAuthorization
|
|
11
11
|
can [:display, :admin], Spree::CustomerReturn
|
|
12
|
+
can [:display, :admin], Spree::OrderCancellations
|
|
13
|
+
can [:display, :admin], Spree::Reimbursement
|
|
14
|
+
can [:display, :admin], Spree::ReturnItem
|
|
15
|
+
can [:display, :admin], Spree::Refund
|
|
12
16
|
end
|
|
13
17
|
end
|
|
14
18
|
end
|
|
@@ -2,10 +2,11 @@ module Spree
|
|
|
2
2
|
module PermissionSets
|
|
3
3
|
class PromotionDisplay < PermissionSets::Base
|
|
4
4
|
def activate!
|
|
5
|
-
can [:display, :admin], Spree::Promotion
|
|
5
|
+
can [:display, :admin, :edit], Spree::Promotion
|
|
6
6
|
can [:display, :admin], Spree::PromotionRule
|
|
7
7
|
can [:display, :admin], Spree::PromotionAction
|
|
8
8
|
can [:display, :admin], Spree::PromotionCategory
|
|
9
|
+
can [:display, :admin], Spree::PromotionCode
|
|
9
10
|
end
|
|
10
11
|
end
|
|
11
12
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PermissionSets
|
|
3
|
+
class RestrictedStockDisplay < PermissionSets::Base
|
|
4
|
+
def activate!
|
|
5
|
+
can [:display, :admin], Spree::StockItem, stock_location_id: location_ids
|
|
6
|
+
can :display, Spree::StockLocation, id: location_ids
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def location_ids
|
|
12
|
+
@ids ||= user.stock_locations.pluck(:id)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PermissionSets
|
|
3
|
+
class RestrictedStockManagement < PermissionSets::Base
|
|
4
|
+
def activate!
|
|
5
|
+
can :manage, Spree::StockItem, stock_location_id: location_ids
|
|
6
|
+
can :display, Spree::StockLocation, id: location_ids
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def location_ids
|
|
12
|
+
@ids ||= user.stock_locations.pluck(:id)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PermissionSets
|
|
3
|
+
class RestrictedStockTransferDisplay < PermissionSets::Base
|
|
4
|
+
def activate!
|
|
5
|
+
can [:display, :admin], Spree::StockTransfer, source_location_id: location_ids
|
|
6
|
+
can [:display, :admin], Spree::StockTransfer, destination_location_id: location_ids
|
|
7
|
+
can :display, Spree::StockLocation, id: location_ids
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def location_ids
|
|
13
|
+
@ids ||= user.stock_locations.pluck(:id)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PermissionSets
|
|
3
|
+
# This is a permission set that offers an alternative to {StockManagement}.
|
|
4
|
+
#
|
|
5
|
+
# Instead of allowing management access for all stock transfers and items, only allow
|
|
6
|
+
# the management of stock transfers for locations the user is associated with.
|
|
7
|
+
#
|
|
8
|
+
# Users can be associated with stock locations via the admin user interface.
|
|
9
|
+
#
|
|
10
|
+
# The logic here is unfortunately rather complex and boils down to:
|
|
11
|
+
# - A user has read only access to all stock locations (including inactive ones)
|
|
12
|
+
# - A user can see all stock transfers for their associated stock locations regardless of the
|
|
13
|
+
# fact that they may not be associated with both the destination and the source, as long as
|
|
14
|
+
# they are associated with at least one of the two.
|
|
15
|
+
# - A user can manage stock transfers only if they are associated with both the destination and the source,
|
|
16
|
+
# or if the user is associated with the source, and the transfer has not yet been assigned a destination.
|
|
17
|
+
#
|
|
18
|
+
# @see Spree::PermissionSets::Base
|
|
19
|
+
class RestrictedStockTransferManagement < PermissionSets::Base
|
|
20
|
+
def activate!
|
|
21
|
+
if user.stock_locations.any?
|
|
22
|
+
can :display, Spree::StockLocation, id: location_ids
|
|
23
|
+
can [:admin, :create], Spree::StockTransfer
|
|
24
|
+
can :display, Spree::StockTransfer, source_location_id: location_ids
|
|
25
|
+
can :display, Spree::StockTransfer, destination_location_id: location_ids
|
|
26
|
+
can :manage, Spree::StockTransfer,
|
|
27
|
+
source_location_id: location_ids,
|
|
28
|
+
destination_location_id: destination_location_ids
|
|
29
|
+
|
|
30
|
+
can :transfer, Spree::StockLocation, id: location_ids
|
|
31
|
+
|
|
32
|
+
can :manage, Spree::TransferItem, stock_transfer: {
|
|
33
|
+
source_location_id: location_ids,
|
|
34
|
+
destination_location_id: destination_location_ids
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def location_ids
|
|
42
|
+
# either source_location_id or destination_location_id can be nil.
|
|
43
|
+
@ids ||= user.stock_locations.pluck(:id)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def destination_location_ids
|
|
47
|
+
location_ids + [nil]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
data/app/models/spree/product.rb
CHANGED
|
@@ -15,12 +15,18 @@ module Spree
|
|
|
15
15
|
|
|
16
16
|
has_many :product_option_types, dependent: :destroy, inverse_of: :product
|
|
17
17
|
has_many :option_types, through: :product_option_types
|
|
18
|
+
|
|
18
19
|
has_many :product_properties, dependent: :destroy, inverse_of: :product
|
|
19
20
|
has_many :properties, through: :product_properties
|
|
21
|
+
has_many :variant_property_rules
|
|
22
|
+
has_many :variant_property_rule_values, through: :variant_property_rules, source: :values
|
|
23
|
+
has_many :variant_property_rule_conditions, through: :variant_property_rules, source: :conditions
|
|
20
24
|
|
|
21
25
|
has_many :classifications, dependent: :delete_all, inverse_of: :product
|
|
22
|
-
has_many :taxons, through: :classifications
|
|
23
|
-
|
|
26
|
+
has_many :taxons, through: :classifications, before_remove: :remove_taxon
|
|
27
|
+
|
|
28
|
+
has_many :product_promotion_rules
|
|
29
|
+
has_many :promotion_rules, through: :product_promotion_rules
|
|
24
30
|
|
|
25
31
|
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
|
|
26
32
|
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :products
|
|
@@ -31,26 +37,33 @@ module Spree
|
|
|
31
37
|
class_name: 'Spree::Variant'
|
|
32
38
|
|
|
33
39
|
has_many :variants,
|
|
34
|
-
-> { where(is_master: false).order(
|
|
40
|
+
-> { where(is_master: false).order(:position) },
|
|
35
41
|
inverse_of: :product,
|
|
36
42
|
class_name: 'Spree::Variant'
|
|
37
43
|
|
|
38
44
|
has_many :variants_including_master,
|
|
39
|
-
-> { order(
|
|
45
|
+
-> { order(:position) },
|
|
40
46
|
inverse_of: :product,
|
|
41
47
|
class_name: 'Spree::Variant',
|
|
42
48
|
dependent: :destroy
|
|
43
49
|
|
|
44
|
-
has_many :prices, -> { order(
|
|
50
|
+
has_many :prices, -> { order(Spree::Variant.arel_table[:position].asc, Spree::Variant.arel_table[:id].asc, :currency) }, through: :variants
|
|
45
51
|
|
|
46
52
|
has_many :stock_items, through: :variants_including_master
|
|
47
53
|
|
|
48
54
|
has_many :line_items, through: :variants_including_master
|
|
49
55
|
has_many :orders, through: :line_items
|
|
50
56
|
|
|
51
|
-
|
|
57
|
+
def find_or_build_master
|
|
58
|
+
master || build_master
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
MASTER_ATTRIBUTES = [:sku, :price, :currency, :display_amount, :display_price, :weight, :height, :width, :depth, :cost_currency, :price_in, :amount_in, :cost_price]
|
|
62
|
+
MASTER_ATTRIBUTES.each do |attr|
|
|
63
|
+
delegate :"#{attr}", :"#{attr}=", to: :find_or_build_master
|
|
64
|
+
end
|
|
52
65
|
|
|
53
|
-
|
|
66
|
+
delegate :display_amount, :display_price, :has_default_price?, to: :find_or_build_master
|
|
54
67
|
|
|
55
68
|
delegate :images, to: :master, prefix: true
|
|
56
69
|
alias_method :images, :master_images
|
|
@@ -82,6 +95,7 @@ module Spree
|
|
|
82
95
|
|
|
83
96
|
attr_accessor :option_values_hash
|
|
84
97
|
|
|
98
|
+
accepts_nested_attributes_for :variant_property_rules, allow_destroy: true
|
|
85
99
|
accepts_nested_attributes_for :product_properties, allow_destroy: true, reject_if: lambda { |pp| pp[:property_name].blank? }
|
|
86
100
|
|
|
87
101
|
alias :options :product_option_types
|
|
@@ -96,11 +110,7 @@ module Spree
|
|
|
96
110
|
|
|
97
111
|
# @return [Spree::TaxCategory] tax category for this product, or the default tax category
|
|
98
112
|
def tax_category
|
|
99
|
-
|
|
100
|
-
TaxCategory.where(is_default: true).first
|
|
101
|
-
else
|
|
102
|
-
TaxCategory.find(self[:tax_category_id])
|
|
103
|
-
end
|
|
113
|
+
super || TaxCategory.find_by(is_default: true)
|
|
104
114
|
end
|
|
105
115
|
|
|
106
116
|
# Overrides the prototype_id setter in order to ensure it is cast to an
|
|
@@ -120,9 +130,10 @@ module Spree
|
|
|
120
130
|
# @return [Array] the option_values
|
|
121
131
|
def ensure_option_types_exist_for_values_hash
|
|
122
132
|
return if option_values_hash.nil?
|
|
123
|
-
option_values_hash.keys.map(&:to_i)
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
required_option_type_ids = option_values_hash.keys.map(&:to_i)
|
|
134
|
+
missing_option_type_ids = required_option_type_ids - option_type_ids
|
|
135
|
+
missing_option_type_ids.each do |id|
|
|
136
|
+
product_option_types.create(option_type_id: id)
|
|
126
137
|
end
|
|
127
138
|
end
|
|
128
139
|
|
|
@@ -168,11 +179,10 @@ module Spree
|
|
|
168
179
|
# @param values [Array{String}] strings to search through fields for
|
|
169
180
|
# @return [ActiveRecord::Relation] scope with WHERE clause for search applied
|
|
170
181
|
def self.like_any(fields, values)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}.inject(:or)
|
|
182
|
+
conditions = fields.product(values).map do |(field, value)|
|
|
183
|
+
arel_table[field].matches("%#{value}%")
|
|
184
|
+
end
|
|
185
|
+
where conditions.inject(:or)
|
|
176
186
|
end
|
|
177
187
|
|
|
178
188
|
# @param current_currency [String] currency to filter variants by; defaults to Spree's default
|
|
@@ -183,6 +193,24 @@ module Spree
|
|
|
183
193
|
end
|
|
184
194
|
end
|
|
185
195
|
|
|
196
|
+
# Groups all of the option values that are associated to the product's variants, grouped by
|
|
197
|
+
# option type.
|
|
198
|
+
#
|
|
199
|
+
# @param variant_scope [ActiveRecord_Associations_CollectionProxy] scope to filter the variants
|
|
200
|
+
# used to determine the applied option_types
|
|
201
|
+
# @return [Hash<Spree::OptionType, Array<Spree::OptionValue>>] all option types and option values
|
|
202
|
+
# associated with the products variants grouped by option type
|
|
203
|
+
def variant_option_values_by_option_type(variant_scope = nil)
|
|
204
|
+
option_value_ids = Spree::OptionValuesVariant.joins(:variant)
|
|
205
|
+
.where(spree_variants: { product_id: self.id})
|
|
206
|
+
.merge(variant_scope)
|
|
207
|
+
.distinct.pluck(:option_value_id)
|
|
208
|
+
Spree::OptionValue.where(id: option_value_ids).
|
|
209
|
+
includes(:option_type).
|
|
210
|
+
order("#{Spree::OptionType.table_name}.position, #{Spree::OptionValue.table_name}.position").
|
|
211
|
+
group_by(&:option_type)
|
|
212
|
+
end
|
|
213
|
+
|
|
186
214
|
# @return [Boolean] true if there are no option values
|
|
187
215
|
def empty_option_values?
|
|
188
216
|
options.empty? || options.any? do |opt|
|
|
@@ -204,11 +232,7 @@ module Spree
|
|
|
204
232
|
def set_property(property_name, property_value)
|
|
205
233
|
ActiveRecord::Base.transaction do
|
|
206
234
|
# Works around spree_i18n #301
|
|
207
|
-
property =
|
|
208
|
-
Property.where(name: property_name).first
|
|
209
|
-
else
|
|
210
|
-
Property.create(name: property_name, presentation: property_name)
|
|
211
|
-
end
|
|
235
|
+
property = Property.create_with(presentation: property_name).find_or_create_by(name: property_name)
|
|
212
236
|
product_property = ProductProperty.where(product: self, property: property).first_or_initialize
|
|
213
237
|
product_property.value = property_value
|
|
214
238
|
product_property.save!
|
|
@@ -237,7 +261,7 @@ module Spree
|
|
|
237
261
|
#
|
|
238
262
|
# @return [Spree::Variant] the master variant
|
|
239
263
|
def master
|
|
240
|
-
super || variants_including_master.with_deleted.
|
|
264
|
+
super || variants_including_master.with_deleted.find_by(is_master: true)
|
|
241
265
|
end
|
|
242
266
|
|
|
243
267
|
# Image that can be used for the product.
|
|
@@ -249,6 +273,16 @@ module Spree
|
|
|
249
273
|
images.first || variant_images.first || Spree::Image.new
|
|
250
274
|
end
|
|
251
275
|
|
|
276
|
+
# Finds the variant property rule that matches the provided option value ids.
|
|
277
|
+
#
|
|
278
|
+
# @param [Array<Integer>] list of option value ids
|
|
279
|
+
# @return [Spree::VariantPropertyRule] the matching variant property rule
|
|
280
|
+
def find_variant_property_rule(option_value_ids)
|
|
281
|
+
variant_property_rules.find do |rule|
|
|
282
|
+
rule.matches_option_value_ids?(option_value_ids)
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
252
286
|
private
|
|
253
287
|
|
|
254
288
|
def add_associations_from_prototype
|
|
@@ -265,7 +299,7 @@ module Spree
|
|
|
265
299
|
if variants_including_master.loaded?
|
|
266
300
|
variants_including_master.any? { |v| !v.should_track_inventory? }
|
|
267
301
|
else
|
|
268
|
-
!Spree::Config.track_inventory_levels || variants_including_master.where(track_inventory: false).
|
|
302
|
+
!Spree::Config.track_inventory_levels || variants_including_master.where(track_inventory: false).exists?
|
|
269
303
|
end
|
|
270
304
|
end
|
|
271
305
|
|
|
@@ -276,7 +310,7 @@ module Spree
|
|
|
276
310
|
values = values.inject(values.shift) { |memo, value| memo.product(value).map(&:flatten) }
|
|
277
311
|
|
|
278
312
|
values.each do |ids|
|
|
279
|
-
|
|
313
|
+
variants.create(
|
|
280
314
|
option_value_ids: ids,
|
|
281
315
|
price: master.price
|
|
282
316
|
)
|
|
@@ -353,6 +387,10 @@ module Spree
|
|
|
353
387
|
Spree::Taxonomy.where(id: taxonomy_ids_to_touch).update_all(updated_at: Time.current)
|
|
354
388
|
end
|
|
355
389
|
|
|
390
|
+
def remove_taxon(taxon)
|
|
391
|
+
removed_classifications = classifications.where(taxon: taxon)
|
|
392
|
+
removed_classifications.each &:remove_from_list
|
|
393
|
+
end
|
|
356
394
|
end
|
|
357
395
|
end
|
|
358
396
|
|