solidus_core 2.10.0.beta1 → 2.10.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +4 -4
- data/app/helpers/spree/products_helper.rb +2 -1
- data/app/jobs/spree/promotion_code_batch_job.rb +2 -2
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +11 -15
- data/app/models/spree/adjustment.rb +11 -0
- data/app/models/spree/calculator/price_sack.rb +1 -1
- data/app/models/spree/calculator/shipping/flexi_rate.rb +2 -2
- data/app/models/spree/calculator/tiered_flat_rate.rb +5 -5
- data/app/models/spree/calculator/tiered_percent.rb +6 -6
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/inventory_unit.rb +1 -19
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/order.rb +3 -2
- data/app/models/spree/order/checkout.rb +1 -1
- data/app/models/spree/order/payments.rb +2 -2
- data/app/models/spree/order_capturing.rb +2 -2
- data/app/models/spree/order_taxation.rb +2 -2
- data/app/models/spree/payment.rb +4 -41
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/payment_method.rb +2 -2
- data/app/models/spree/product.rb +3 -3
- data/app/models/spree/product/scopes.rb +9 -8
- data/app/models/spree/promotion.rb +27 -12
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +1 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
- data/app/models/spree/promotion/rules/option_value.rb +2 -2
- data/app/models/spree/promotion/rules/product.rb +3 -3
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_chooser.rb +2 -2
- data/app/models/spree/promotion_code.rb +9 -8
- data/app/models/spree/promotion_code/batch_builder.rb +3 -3
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/refund.rb +2 -2
- data/app/models/spree/reimbursement.rb +3 -11
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -1
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +2 -2
- data/app/models/spree/return_authorization.rb +1 -7
- data/app/models/spree/return_item.rb +3 -42
- data/app/models/spree/return_item/eligibility_validator/default.rb +1 -1
- data/app/models/spree/shipment.rb +4 -38
- data/app/models/spree/shipping_calculator.rb +0 -4
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/stock/differentiator.rb +1 -1
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_quantities.rb +13 -12
- data/app/models/spree/tax_calculator/default.rb +0 -4
- data/app/models/spree/tax_calculator/shipping_rate.rb +0 -3
- data/app/models/spree/tax_rate.rb +4 -0
- data/app/models/spree/taxon/paperclip_attachment.rb +13 -0
- data/app/models/spree/user_last_url_storer.rb +46 -0
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +36 -0
- data/app/models/spree/variant.rb +9 -9
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
- data/app/models/spree/zone.rb +1 -1
- data/config/initializers/money.rb +2 -0
- data/config/locales/en.yml +12 -0
- data/lib/generators/spree/install/install_generator.rb +3 -0
- data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +8 -0
- data/lib/spree/app_configuration.rb +18 -3
- data/lib/spree/core.rb +12 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -13
- data/lib/spree/core/controller_helpers/strong_parameters.rb +21 -7
- data/lib/spree/core/engine.rb +2 -2
- data/lib/spree/core/environment_extension.rb +9 -0
- data/lib/spree/core/importer/order.rb +27 -26
- data/lib/spree/core/product_filters.rb +15 -15
- data/lib/spree/core/role_configuration.rb +2 -2
- data/lib/spree/core/search/variant.rb +1 -1
- data/lib/spree/core/state_machines.rb +78 -0
- data/lib/spree/core/state_machines/inventory_unit.rb +42 -0
- data/lib/spree/core/state_machines/payment.rb +61 -0
- data/lib/spree/core/state_machines/reimbursement.rb +33 -0
- data/lib/spree/core/state_machines/return_authorization.rb +32 -0
- data/lib/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
- data/lib/spree/core/state_machines/return_item/reception_status.rb +42 -0
- data/lib/spree/core/state_machines/shipment.rb +58 -0
- data/lib/spree/core/stock_configuration.rb +1 -0
- data/lib/spree/core/validators/email.rb +1 -8
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +2 -2
- data/lib/spree/permission_sets/user_management.rb +3 -0
- data/lib/spree/permitted_attributes.rb +78 -9
- data/lib/spree/preferences/static_model_preferences.rb +2 -2
- data/lib/spree/testing_support/dummy_app.rb +4 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +8 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -0
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -1
- data/solidus_core.gemspec +4 -4
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +8 -1
- data/spec/lib/spree/core/environment_extension_spec.rb +12 -1
- data/spec/lib/spree/core/stock_configuration_spec.rb +36 -0
- data/spec/lib/spree/core/validators/email_spec.rb +18 -18
- data/spec/lib/spree/permitted_attributes_spec.rb +41 -0
- data/spec/models/spree/ability_spec.rb +1 -1
- data/spec/models/spree/address_spec.rb +23 -0
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +1 -1
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +24 -15
- data/spec/models/spree/carton_spec.rb +8 -0
- data/spec/models/spree/classification_spec.rb +21 -9
- data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
- data/spec/models/spree/concerns/user_methods_spec.rb +2 -1
- data/spec/models/spree/order_merger_spec.rb +3 -3
- data/spec/models/spree/order_spec.rb +8 -15
- data/spec/models/spree/order_updater_spec.rb +4 -3
- data/spec/models/spree/payment_create_spec.rb +4 -14
- data/spec/models/spree/permission_sets/user_management_spec.rb +2 -0
- data/spec/models/spree/preference_spec.rb +4 -4
- data/spec/models/spree/preferences/preferable_spec.rb +3 -3
- data/spec/models/spree/preferences/statically_configurable_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/taxon_spec.rb +1 -0
- data/spec/models/spree/promotion_rule_spec.rb +6 -6
- data/spec/models/spree/promotion_spec.rb +73 -52
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +1 -1
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +1 -1
- data/spec/models/spree/returns_calculator_spec.rb +2 -2
- data/spec/models/spree/shipping_calculator_spec.rb +1 -13
- data/spec/models/spree/shipping_method_spec.rb +32 -0
- data/spec/models/spree/stock/availability_validator_spec.rb +2 -2
- data/spec/models/spree/stock/differentiator_spec.rb +2 -2
- data/spec/models/spree/stock/estimator_spec.rb +3 -3
- data/spec/models/spree/stock/package_spec.rb +28 -28
- data/spec/models/spree/stock/simple_coordinator_spec.rb +11 -11
- data/spec/models/spree/stock/splitter/base_spec.rb +4 -4
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +7 -7
- data/spec/models/spree/stock_quantities_spec.rb +1 -1
- data/spec/models/spree/store_credit_spec.rb +1 -1
- data/spec/models/spree/tax_rate_spec.rb +1 -0
- data/spec/models/spree/taxons/paperclip_attachment_spec.rb +29 -0
- data/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb +31 -0
- data/spec/models/spree/user_last_url_storer_spec.rb +60 -0
- metadata +41 -35
- data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +0 -162
- data/spec/models/spree/order/updating_spec.rb +0 -18
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
# Inventory Units' state machine
|
7
|
+
#
|
8
|
+
# for each event the following instance methods are dynamically implemented:
|
9
|
+
# #<event_name>
|
10
|
+
# #<event_name>!
|
11
|
+
# #can_<event_name>?
|
12
|
+
#
|
13
|
+
# for each state the following instance methods are implemented:
|
14
|
+
# #<state_name>?
|
15
|
+
#
|
16
|
+
module InventoryUnit
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
state_machine initial: :on_hand do
|
21
|
+
event :fill_backorder do
|
22
|
+
transition to: :on_hand, from: :backordered
|
23
|
+
end
|
24
|
+
after_transition on: :fill_backorder, do: :fulfill_order
|
25
|
+
|
26
|
+
event :ship do
|
27
|
+
transition to: :shipped, if: :allow_ship?
|
28
|
+
end
|
29
|
+
|
30
|
+
event :return do
|
31
|
+
transition to: :returned, from: :shipped
|
32
|
+
end
|
33
|
+
|
34
|
+
event :cancel do
|
35
|
+
transition to: :canceled, from: ::Spree::InventoryUnit::CANCELABLE_STATES.map(&:to_sym)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
# Payments' state machine
|
7
|
+
#
|
8
|
+
# for each event the following instance methods are dynamically implemented:
|
9
|
+
# #<event_name>
|
10
|
+
# #<event_name>!
|
11
|
+
# #can_<event_name>?
|
12
|
+
#
|
13
|
+
# for each state the following instance methods are implemented:
|
14
|
+
# #<state_name>?
|
15
|
+
#
|
16
|
+
module Payment
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
state_machine initial: :checkout do
|
21
|
+
# With card payments, happens before purchase or authorization happens
|
22
|
+
#
|
23
|
+
# Setting it after creating a profile and authorizing a full amount will
|
24
|
+
# prevent the payment from being authorized again once Order transitions
|
25
|
+
# to complete
|
26
|
+
event :started_processing do
|
27
|
+
transition from: [:checkout, :pending, :completed, :processing], to: :processing
|
28
|
+
end
|
29
|
+
# When processing during checkout fails
|
30
|
+
event :failure do
|
31
|
+
transition from: [:pending, :processing], to: :failed
|
32
|
+
end
|
33
|
+
# With card payments this represents authorizing the payment
|
34
|
+
event :pend do
|
35
|
+
transition from: [:checkout, :processing], to: :pending
|
36
|
+
end
|
37
|
+
# With card payments this represents completing a purchase or capture transaction
|
38
|
+
event :complete do
|
39
|
+
transition from: [:processing, :pending, :checkout], to: :completed
|
40
|
+
end
|
41
|
+
event :void do
|
42
|
+
transition from: [:pending, :processing, :completed, :checkout], to: :void
|
43
|
+
end
|
44
|
+
# when the card brand isnt supported
|
45
|
+
event :invalidate do
|
46
|
+
transition from: [:checkout], to: :invalid
|
47
|
+
end
|
48
|
+
|
49
|
+
after_transition do |payment, transition|
|
50
|
+
payment.state_changes.create!(
|
51
|
+
previous_state: transition.from,
|
52
|
+
next_state: transition.to,
|
53
|
+
name: 'payment'
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
# Reimbursement' state machine
|
7
|
+
#
|
8
|
+
# for each event the following instance methods are dynamically implemented:
|
9
|
+
# #<event_name>
|
10
|
+
# #<event_name>!
|
11
|
+
# #can_<event_name>?
|
12
|
+
#
|
13
|
+
# for each state the following instance methods are implemented:
|
14
|
+
# #<state_name>?
|
15
|
+
#
|
16
|
+
module Reimbursement
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
state_machine :reimbursement_status, initial: :pending do
|
21
|
+
event :errored do
|
22
|
+
transition to: :errored, from: [:pending, :errored]
|
23
|
+
end
|
24
|
+
|
25
|
+
event :reimbursed do
|
26
|
+
transition to: :reimbursed, from: [:pending, :errored]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
# Return Authorizations' state machine
|
7
|
+
#
|
8
|
+
# for each event the following instance methods are dynamically implemented:
|
9
|
+
# #<event_name>
|
10
|
+
# #<event_name>!
|
11
|
+
# #can_<event_name>?
|
12
|
+
#
|
13
|
+
# for each state the following instance methods are implemented:
|
14
|
+
# #<state_name>?
|
15
|
+
#
|
16
|
+
module ReturnAuthorization
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
state_machine initial: :authorized do
|
21
|
+
before_transition to: :canceled, do: :cancel_return_items
|
22
|
+
|
23
|
+
event :cancel do
|
24
|
+
transition to: :canceled, from: :authorized,
|
25
|
+
if: lambda { |return_authorization| return_authorization.can_cancel_return_items? }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
module ReturnItem
|
7
|
+
# Return Items' acceptance status state machine
|
8
|
+
#
|
9
|
+
# for each event the following instance methods are dynamically implemented:
|
10
|
+
# #<event_name>
|
11
|
+
# #<event_name>!
|
12
|
+
# #can_<event_name>?
|
13
|
+
#
|
14
|
+
# for each state the following instance methods are implemented:
|
15
|
+
# #<state_name>?
|
16
|
+
#
|
17
|
+
module AcceptanceStatus
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
|
20
|
+
included do
|
21
|
+
state_machine :acceptance_status, initial: :pending do
|
22
|
+
event :attempt_accept do
|
23
|
+
transition to: :accepted, from: :accepted
|
24
|
+
transition to: :accepted, from: :pending, if: ->(return_item) { return_item.eligible_for_return? }
|
25
|
+
transition to: :manual_intervention_required, from: :pending, if: ->(return_item) { return_item.requires_manual_intervention? }
|
26
|
+
transition to: :rejected, from: :pending
|
27
|
+
end
|
28
|
+
|
29
|
+
# bypasses eligibility checks
|
30
|
+
event :accept do
|
31
|
+
transition to: :accepted, from: [:accepted, :pending, :manual_intervention_required]
|
32
|
+
end
|
33
|
+
|
34
|
+
# bypasses eligibility checks
|
35
|
+
event :reject do
|
36
|
+
transition to: :rejected, from: [:accepted, :pending, :manual_intervention_required]
|
37
|
+
end
|
38
|
+
|
39
|
+
# bypasses eligibility checks
|
40
|
+
event :require_manual_intervention do
|
41
|
+
transition to: :manual_intervention_required, from: [:accepted, :pending, :manual_intervention_required]
|
42
|
+
end
|
43
|
+
|
44
|
+
after_transition any => any, do: :persist_acceptance_status_errors
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
module ReturnItem
|
7
|
+
# Return Items' reception status state machine
|
8
|
+
#
|
9
|
+
# for each event the following instance methods are dynamically implemented:
|
10
|
+
# #<event_name>
|
11
|
+
# #<event_name>!
|
12
|
+
# #can_<event_name>?
|
13
|
+
#
|
14
|
+
# for each state the following instance methods are implemented:
|
15
|
+
# #<state_name>?
|
16
|
+
#
|
17
|
+
module ReceptionStatus
|
18
|
+
extend ActiveSupport::Concern
|
19
|
+
|
20
|
+
included do
|
21
|
+
state_machine :reception_status, initial: :awaiting do
|
22
|
+
after_transition to: ::Spree::ReturnItem::COMPLETED_RECEPTION_STATUSES, do: :attempt_accept
|
23
|
+
after_transition to: ::Spree::ReturnItem::COMPLETED_RECEPTION_STATUSES, do: :check_unexchange
|
24
|
+
after_transition to: :received, do: :process_inventory_unit!
|
25
|
+
|
26
|
+
event(:cancel) { transition to: :cancelled, from: :awaiting }
|
27
|
+
|
28
|
+
event(:receive) { transition to: :received, from: ::Spree::ReturnItem::INTERMEDIATE_RECEPTION_STATUSES + [:awaiting] }
|
29
|
+
event(:unexchange) { transition to: :unexchanged, from: [:awaiting] }
|
30
|
+
event(:give) { transition to: :given_to_customer, from: :awaiting }
|
31
|
+
event(:lost) { transition to: :lost_in_transit, from: :awaiting }
|
32
|
+
event(:wrong_item_shipped) { transition to: :shipped_wrong_item, from: :awaiting }
|
33
|
+
event(:short_shipped) { transition to: :short_shipped, from: :awaiting }
|
34
|
+
event(:in_transit) { transition to: :in_transit, from: :awaiting }
|
35
|
+
event(:expired) { transition to: :expired, from: :awaiting }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Core
|
5
|
+
class StateMachines
|
6
|
+
# Shipments' state machine
|
7
|
+
#
|
8
|
+
# for each event the following instance methods are dynamically implemented:
|
9
|
+
# #<event_name>
|
10
|
+
# #<event_name>!
|
11
|
+
# #can_<event_name>?
|
12
|
+
#
|
13
|
+
# for each state the following instance methods are implemented:
|
14
|
+
# #<state_name>?
|
15
|
+
#
|
16
|
+
module Shipment
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
included do
|
20
|
+
state_machine initial: :pending, use_transactions: false do
|
21
|
+
event :ready do
|
22
|
+
transition from: :pending, to: :shipped, if: :can_transition_from_pending_to_shipped?
|
23
|
+
transition from: :pending, to: :ready, if: :can_transition_from_pending_to_ready?
|
24
|
+
end
|
25
|
+
|
26
|
+
event :pend do
|
27
|
+
transition from: :ready, to: :pending
|
28
|
+
end
|
29
|
+
|
30
|
+
event :ship do
|
31
|
+
transition from: [:ready, :canceled], to: :shipped
|
32
|
+
end
|
33
|
+
after_transition to: :shipped, do: :after_ship
|
34
|
+
|
35
|
+
event :cancel do
|
36
|
+
transition to: :canceled, from: [:pending, :ready]
|
37
|
+
end
|
38
|
+
after_transition to: :canceled, do: :after_cancel
|
39
|
+
|
40
|
+
event :resume do
|
41
|
+
transition from: :canceled, to: :ready, if: :can_transition_from_canceled_to_ready?
|
42
|
+
transition from: :canceled, to: :pending
|
43
|
+
end
|
44
|
+
after_transition from: :canceled, to: [:pending, :ready, :shipped], do: :after_resume
|
45
|
+
|
46
|
+
after_transition do |shipment, transition|
|
47
|
+
shipment.state_changes.create!(
|
48
|
+
previous_state: transition.from,
|
49
|
+
next_state: transition.to,
|
50
|
+
name: 'shipment'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -15,16 +15,9 @@ module Spree
|
|
15
15
|
EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
|
16
16
|
|
17
17
|
def validate_each(record, attribute, value)
|
18
|
-
unless value
|
18
|
+
unless EMAIL_REGEXP.match? value
|
19
19
|
record.errors.add(attribute, :invalid, { value: value }.merge!(options))
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
# @private
|
26
|
-
EmailValidator = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
|
27
|
-
'EmailValidator',
|
28
|
-
'Spree::EmailValidator',
|
29
|
-
message: "EmailValidator is deprecated! Use Spree::EmailValidator instead.\nChange `validates :email, email: true` to `validates :email, 'spree/email' => true`\n"
|
30
|
-
)
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/money.rb
CHANGED
@@ -82,9 +82,9 @@ module Spree
|
|
82
82
|
# Maintain compatibility by checking html option renamed to html_wrap.
|
83
83
|
if options[:html] || options[:html] == false
|
84
84
|
Spree::Deprecation.warn <<-WARN.squish, caller
|
85
|
-
Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html]}),
|
85
|
+
Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html].inspect}),
|
86
86
|
which will not be supported in the future.
|
87
|
-
Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html]})
|
87
|
+
Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html].inspect})
|
88
88
|
WARN
|
89
89
|
end
|
90
90
|
if options[:html_wrap] || options[:html]
|
@@ -11,6 +11,9 @@ module Spree
|
|
11
11
|
can :update_email, Spree.user_class do |user|
|
12
12
|
user.spree_roles.none?
|
13
13
|
end
|
14
|
+
can :update_password, Spree.user_class do |user|
|
15
|
+
user.spree_roles.none?
|
16
|
+
end
|
14
17
|
|
15
18
|
cannot [:delete, :destroy], Spree.user_class
|
16
19
|
can :manage, Spree::StoreCredit
|
@@ -8,7 +8,10 @@ module Spree
|
|
8
8
|
ATTRIBUTES = [
|
9
9
|
:address_attributes,
|
10
10
|
:address_book_attributes,
|
11
|
-
:
|
11
|
+
:checkout_address_attributes,
|
12
|
+
:checkout_delivery_attributes,
|
13
|
+
:checkout_payment_attributes,
|
14
|
+
:checkout_confirm_attributes,
|
12
15
|
:credit_card_update_attributes,
|
13
16
|
:customer_return_attributes,
|
14
17
|
:image_attributes,
|
@@ -45,10 +48,6 @@ module Spree
|
|
45
48
|
|
46
49
|
@@address_book_attributes = address_attributes + [:default]
|
47
50
|
|
48
|
-
@@checkout_attributes = [
|
49
|
-
:coupon_code, :email, :special_instructions, :use_billing
|
50
|
-
]
|
51
|
-
|
52
51
|
@@credit_card_update_attributes = [
|
53
52
|
:month, :year, :expiry, :first_name, :last_name, :name
|
54
53
|
]
|
@@ -91,7 +90,7 @@ module Spree
|
|
91
90
|
:number, :month, :year, :expiry, :verification_value,
|
92
91
|
:first_name, :last_name, :cc_type, :gateway_customer_profile_id,
|
93
92
|
:gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
|
94
|
-
:existing_card_id, :wallet_payment_source_id
|
93
|
+
:existing_card_id, :wallet_payment_source_id, address_attributes: address_attributes
|
95
94
|
]
|
96
95
|
|
97
96
|
@@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
|
@@ -117,10 +116,10 @@ module Spree
|
|
117
116
|
:meta_description, :meta_keywords, :meta_title, :child_index
|
118
117
|
]
|
119
118
|
|
120
|
-
#
|
119
|
+
# Intentionally leaving off email here to prevent privilege escalation
|
121
120
|
# by changing a user with higher priveleges' email to one a lower-priveleged
|
122
|
-
# admin owns.
|
123
|
-
# controller level
|
121
|
+
# admin owns. Creating a user with an email is handled separate at the
|
122
|
+
# controller level.
|
124
123
|
@@user_attributes = [:password, :password_confirmation]
|
125
124
|
|
126
125
|
@@variant_attributes = [
|
@@ -129,5 +128,75 @@ module Spree
|
|
129
128
|
:product_id, :product, :option_values_attributes, :price,
|
130
129
|
:weight, :height, :width, :depth, :sku, :cost_currency, option_value_ids: [], options: [:name, :value]
|
131
130
|
]
|
131
|
+
|
132
|
+
@@checkout_address_attributes = [
|
133
|
+
:use_billing,
|
134
|
+
:email,
|
135
|
+
bill_address_attributes: address_attributes,
|
136
|
+
ship_address_attributes: address_attributes
|
137
|
+
]
|
138
|
+
|
139
|
+
@@checkout_delivery_attributes = [
|
140
|
+
:special_instructions,
|
141
|
+
shipments_attributes: shipment_attributes
|
142
|
+
]
|
143
|
+
|
144
|
+
@@checkout_payment_attributes = [
|
145
|
+
:coupon_code,
|
146
|
+
payments_attributes: payment_attributes + [
|
147
|
+
source_attributes: source_attributes
|
148
|
+
]
|
149
|
+
]
|
150
|
+
|
151
|
+
@@checkout_confirm_attributes = []
|
152
|
+
|
153
|
+
def self.checkout_attributes
|
154
|
+
Spree::Deprecation.warn <<-WARN.squish, caller
|
155
|
+
checkout_attributes is deprecated, please use the permitted
|
156
|
+
attributes set for the specific step that needs to be updated.
|
157
|
+
|
158
|
+
E.g. permitted_checkout_address_attributes
|
159
|
+
WARN
|
160
|
+
|
161
|
+
CheckoutAdditionalAttributes.new(
|
162
|
+
checkout_address_attributes +
|
163
|
+
checkout_delivery_attributes +
|
164
|
+
checkout_payment_attributes +
|
165
|
+
checkout_confirm_attributes
|
166
|
+
)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class CheckoutAdditionalAttributes < Array
|
171
|
+
def <<(*attributes)
|
172
|
+
super
|
173
|
+
|
174
|
+
inject_attributes_to_all_steps(attributes, :<<)
|
175
|
+
end
|
176
|
+
|
177
|
+
def push(*attributes)
|
178
|
+
super
|
179
|
+
|
180
|
+
inject_attributes_to_all_steps(attributes, :push)
|
181
|
+
end
|
182
|
+
alias append push
|
183
|
+
|
184
|
+
def prepend(*attributes)
|
185
|
+
super
|
186
|
+
|
187
|
+
inject_attributes_to_all_steps(attributes, :prepend)
|
188
|
+
end
|
189
|
+
alias unshift prepend
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
def inject_attributes_to_all_steps(attributes, method)
|
194
|
+
attributes.each do |attribute|
|
195
|
+
PermittedAttributes.checkout_address_attributes.send(method, attribute)
|
196
|
+
PermittedAttributes.checkout_delivery_attributes.send(method, attribute)
|
197
|
+
PermittedAttributes.checkout_payment_attributes.send(method, attribute)
|
198
|
+
PermittedAttributes.checkout_confirm_attributes.send(method, attribute)
|
199
|
+
end
|
200
|
+
end
|
132
201
|
end
|
133
202
|
end
|