solidus_core 2.8.6 → 2.9.0.rc.1

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.

Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/logo/solidus.svg +1 -18
  3. data/app/assets/images/logo/solidus_logo.png +0 -0
  4. data/app/mailers/spree/test_mailer.rb +2 -0
  5. data/app/models/concerns/spree/default_price.rb +1 -1
  6. data/app/models/concerns/spree/ransackable_attributes.rb +1 -1
  7. data/app/models/concerns/spree/user_reporting.rb +1 -1
  8. data/app/models/spree/billing_integration.rb +7 -2
  9. data/app/models/spree/country.rb +2 -0
  10. data/app/models/spree/customer_return.rb +1 -1
  11. data/app/models/spree/image.rb +2 -44
  12. data/app/models/spree/image/paperclip_attachment.rb +55 -0
  13. data/app/models/spree/inventory_unit.rb +0 -1
  14. data/app/models/spree/option_type.rb +2 -0
  15. data/app/models/spree/option_value.rb +1 -1
  16. data/app/models/spree/order.rb +8 -13
  17. data/app/models/spree/payment.rb +1 -1
  18. data/app/models/spree/payment_method.rb +8 -4
  19. data/app/models/spree/product.rb +1 -1
  20. data/app/models/spree/promotion.rb +18 -11
  21. data/app/models/spree/promotion/rules/first_order.rb +1 -3
  22. data/app/models/spree/promotion/rules/item_total.rb +9 -1
  23. data/app/models/spree/promotion/rules/one_use_per_user.rb +2 -2
  24. data/app/models/spree/promotion/rules/product.rb +3 -3
  25. data/app/models/spree/promotion/rules/taxon.rb +5 -8
  26. data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
  27. data/app/models/spree/promotion_handler/coupon.rb +19 -3
  28. data/app/models/spree/property.rb +2 -0
  29. data/app/models/spree/reimbursement.rb +5 -5
  30. data/app/models/spree/return_item.rb +6 -2
  31. data/app/models/spree/state.rb +6 -0
  32. data/app/models/spree/stock/location_filter/active.rb +14 -0
  33. data/app/models/spree/stock/location_filter/base.rb +43 -0
  34. data/app/models/spree/stock/simple_coordinator.rb +4 -1
  35. data/app/models/spree/stock_location.rb +2 -0
  36. data/app/models/spree/tax_category.rb +11 -0
  37. data/app/models/spree/taxon.rb +4 -11
  38. data/app/models/spree/taxon/paperclip_attachment.rb +21 -0
  39. data/app/models/spree/taxonomy.rb +2 -0
  40. data/app/models/spree/unit_cancel.rb +12 -1
  41. data/app/models/spree/variant.rb +1 -1
  42. data/app/models/spree/variant/pricing_options.rb +10 -0
  43. data/app/models/spree/wallet_payment_source.rb +26 -10
  44. data/app/models/spree/zone.rb +1 -1
  45. data/app/views/spree/order_mailer/inventory_cancellation_email.text.erb +3 -3
  46. data/config/locales/en.yml +26 -53
  47. data/db/default/spree/store_credit.rb +1 -0
  48. data/db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb +1 -1
  49. data/db/migrate/20170608074534_rename_bogus_gateways.rb +9 -8
  50. data/db/migrate/20190220093635_drop_spree_store_credit_update_reasons.rb +19 -0
  51. data/lib/generators/spree/install/install_generator.rb +0 -3
  52. data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +3 -0
  53. data/lib/solidus/migrations/rename_gateways.rb +2 -0
  54. data/lib/spree/app_configuration.rb +24 -0
  55. data/lib/spree/core.rb +1 -0
  56. data/lib/spree/core/controller_helpers/pricing.rb +1 -4
  57. data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -21
  58. data/lib/spree/core/engine.rb +5 -0
  59. data/lib/spree/core/importer/order.rb +1 -3
  60. data/lib/spree/core/stock_configuration.rb +5 -0
  61. data/lib/spree/core/version.rb +3 -1
  62. data/lib/spree/deprecation.rb +50 -0
  63. data/lib/spree/event.rb +111 -0
  64. data/lib/spree/event/adapters/active_support_notifications.rb +35 -0
  65. data/lib/spree/event/configuration.rb +17 -0
  66. data/lib/spree/event/processors/mailer_processor.rb +27 -0
  67. data/lib/spree/event/subscriber.rb +84 -0
  68. data/lib/spree/permitted_attributes.rb +7 -76
  69. data/lib/spree/testing_support/capybara_ext.rb +15 -0
  70. data/lib/spree/testing_support/common_rake.rb +1 -1
  71. data/lib/spree/testing_support/dummy_app.rb +3 -10
  72. data/lib/spree/testing_support/factories/promotion_factory.rb +10 -0
  73. data/lib/spree/testing_support/factories/return_item_factory.rb +1 -0
  74. data/lib/spree/testing_support/preferences.rb +62 -0
  75. data/lib/tasks/email.rake +2 -0
  76. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +4 -0
  77. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +2 -0
  78. data/lib/tasks/migrations/migrate_user_addresses.rake +3 -0
  79. data/lib/tasks/migrations/rename_gateways.rake +2 -0
  80. data/lib/tasks/order_capturing.rake +2 -0
  81. data/spec/helpers/base_helper_spec.rb +3 -3
  82. data/spec/helpers/products_helper_spec.rb +2 -2
  83. data/spec/{models → lib}/spree/app_configuration_spec.rb +11 -1
  84. data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +13 -0
  85. data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +1 -8
  86. data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +1 -1
  87. data/spec/lib/spree/core/testing_support/preferences_spec.rb +33 -0
  88. data/spec/lib/spree/event/subscriber_spec.rb +85 -0
  89. data/spec/lib/spree/event_spec.rb +92 -0
  90. data/spec/lib/spree/money_spec.rb +3 -9
  91. data/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +5 -3
  92. data/spec/mailers/order_mailer_spec.rb +1 -1
  93. data/spec/mailers/test_mailer_spec.rb +3 -1
  94. data/spec/models/spree/address_spec.rb +5 -4
  95. data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
  96. data/spec/models/spree/country_spec.rb +5 -5
  97. data/spec/models/spree/customer_return_spec.rb +1 -1
  98. data/spec/models/spree/order/checkout_spec.rb +3 -7
  99. data/spec/models/spree/order/finalizing_spec.rb +1 -1
  100. data/spec/models/spree/order/payment_spec.rb +3 -3
  101. data/spec/models/spree/order_inventory_spec.rb +1 -1
  102. data/spec/models/spree/order_spec.rb +67 -2
  103. data/spec/models/spree/order_updater_spec.rb +2 -2
  104. data/spec/models/spree/payment_spec.rb +12 -0
  105. data/spec/models/spree/product_spec.rb +3 -3
  106. data/spec/models/spree/promotion/rules/first_order_spec.rb +13 -3
  107. data/spec/models/spree/promotion/rules/item_total_spec.rb +15 -0
  108. data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +10 -0
  109. data/spec/models/spree/promotion/rules/product_spec.rb +15 -0
  110. data/spec/models/spree/promotion/rules/taxon_spec.rb +59 -8
  111. data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +5 -0
  112. data/spec/models/spree/promotion_handler/shipping_spec.rb +1 -1
  113. data/spec/models/spree/promotion_spec.rb +80 -0
  114. data/spec/models/spree/reimbursement_spec.rb +3 -2
  115. data/spec/models/spree/return_item_spec.rb +9 -0
  116. data/spec/models/spree/shipment_spec.rb +3 -3
  117. data/spec/models/spree/stock/availability_spec.rb +1 -1
  118. data/spec/models/spree/stock/estimator_spec.rb +5 -7
  119. data/spec/models/spree/stock/location_filter/active_spec.rb +22 -0
  120. data/spec/models/spree/stock/location_sorter/default_first_spec.rb +4 -2
  121. data/spec/models/spree/stock/location_sorter/unsorted_spec.rb +3 -1
  122. data/spec/models/spree/stock/quantifier_spec.rb +1 -1
  123. data/spec/models/spree/stock/simple_coordinator_spec.rb +5 -0
  124. data/spec/models/spree/stock_item_spec.rb +3 -2
  125. data/spec/models/spree/stock_movement_spec.rb +1 -1
  126. data/spec/models/spree/store_credit_spec.rb +1 -1
  127. data/spec/models/spree/tax/order_adjuster_spec.rb +1 -1
  128. data/spec/models/spree/tax/taxation_integration_spec.rb +1 -1
  129. data/spec/models/spree/tax_category_spec.rb +21 -0
  130. data/spec/models/spree/taxon_spec.rb +28 -0
  131. data/spec/models/spree/unit_cancel_spec.rb +41 -0
  132. data/spec/models/spree/user_spec.rb +3 -3
  133. data/spec/models/spree/variant/pricing_options_spec.rb +23 -0
  134. data/spec/models/spree/variant/vat_price_generator_spec.rb +1 -1
  135. data/spec/models/spree/variant_spec.rb +11 -8
  136. data/spec/models/spree/wallet_payment_source_spec.rb +35 -6
  137. data/spec/models/spree/wallet_spec.rb +1 -1
  138. data/spec/spec_helper.rb +0 -4
  139. data/spec/support/concerns/default_price.rb +8 -0
  140. metadata +18 -5
  141. data/spec/lib/spree/permitted_attributes_spec.rb +0 -41
@@ -4,4 +4,54 @@ require 'active_support/deprecation'
4
4
 
5
5
  module Spree
6
6
  Deprecation = ActiveSupport::Deprecation.new('3.0', 'Solidus')
7
+
8
+ # This DeprecatedInstanceVariableProxy transforms instance variable to
9
+ # deprecated instance variable.
10
+ #
11
+ # It differs from ActiveSupport::DeprecatedInstanceVariableProxy since
12
+ # it allows to define a custom message.
13
+ #
14
+ # class Example
15
+ # def initialize(deprecator)
16
+ # @request = Spree::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator, "Please, do not use this thing.")
17
+ # @_request = :a_request
18
+ # end
19
+ #
20
+ # def request
21
+ # @_request
22
+ # end
23
+ #
24
+ # def old_request
25
+ # @request
26
+ # end
27
+ # end
28
+ #
29
+ # When someone execute any method on @request variable this will trigger
30
+ # +warn+ method on +deprecator_instance+ and will fetch <tt>@_request</tt>
31
+ # variable via +request+ method and execute the same method on non-proxy
32
+ # instance variable.
33
+ #
34
+ # Default deprecator is <tt>Spree::Deprecation</tt>.
35
+ class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy
36
+ def initialize(instance, method, var = "@#{method}", deprecator = Spree::Deprecation, message = nil)
37
+ @instance = instance
38
+ @method = method
39
+ @var = var
40
+ @deprecator = deprecator
41
+ @message = message
42
+ end
43
+
44
+ private
45
+
46
+ def target
47
+ @instance.__send__(@method)
48
+ end
49
+
50
+ def warn(callstack, called, args)
51
+ message = @message || "#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}."
52
+ message = [message, "Args: #{args.inspect}"].join(" ")
53
+
54
+ @deprecator.warn(message, callstack)
55
+ end
56
+ end
7
57
  end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'event/adapters/active_support_notifications'
4
+ require_relative 'event/configuration'
5
+ require_relative 'event/subscriber'
6
+
7
+ module Spree
8
+ module Event
9
+ extend self
10
+
11
+ # Allows to trigger events that can be subscribed using #subscribe. An
12
+ # optional block can be passed that will be executed immediately. The
13
+ # actual code implementation is delegated to the adapter.
14
+ #
15
+ # @param [String] event_name the name of the event. The suffix ".spree"
16
+ # will be added automatically if not present
17
+ # @param [Hash] opts a list of options to be passed to the triggered event
18
+ #
19
+ # @example Trigger an event named 'order_finalized'
20
+ # Spree::Event.fire 'order_finalized', order: @order do
21
+ # @order.finalize!
22
+ # end
23
+ def fire(event_name, opts = {})
24
+ adapter.fire name_with_suffix(event_name), opts do
25
+ yield opts if block_given?
26
+ end
27
+ end
28
+
29
+ # Subscribe to an event with the given name. The provided block is executed
30
+ # every time the subscribed event is fired.
31
+ #
32
+ # @param [String] event_name the name of the event. The suffix ".spree"
33
+ # will be added automatically if not present
34
+ #
35
+ # @return a subscription object that can be used as reference in order
36
+ # to remove the subscription
37
+ #
38
+ # @example Subscribe to the `order_finalized` event
39
+ # Spree::Event.subscribe 'order_finalized' do |event|
40
+ # order = event.payload[:order]
41
+ # Spree::Mailer.order_finalized(order).deliver_later
42
+ # end
43
+ #
44
+ # @see Spree::Event#unsubscribe
45
+ def subscribe(event_name, &block)
46
+ name = name_with_suffix(event_name)
47
+ listener_names << name
48
+ adapter.subscribe(name, &block)
49
+ end
50
+
51
+ # Unsubscribes a whole event or a specific subscription object
52
+ #
53
+ # @param [String, Object] subscriber the event name as a string (with
54
+ # or without the ".spree" suffix) or the subscription object
55
+ #
56
+ # @example Unsubscribe a single subscription
57
+ # subscription = Spree::Event.fire 'order_finalized'
58
+ # Spree::Event.unsubscribe(subscription)
59
+ # @example Unsubscribe all `order_finalized` event subscriptions
60
+ # Spree::Event.unsubscribe('order_finalized')
61
+ # @example Unsubscribe an event by name with explicit prefix
62
+ # Spree::Event.unsubscribe('order_finalized.spree')
63
+ def unsubscribe(subscriber)
64
+ name_or_subscriber = subscriber.is_a?(String) ? name_with_suffix(subscriber) : subscriber
65
+ adapter.unsubscribe(name_or_subscriber)
66
+ end
67
+
68
+ # Lists all subscriptions currently registered under the ".spree"
69
+ # namespace. Actual implementation is delegated to the adapter
70
+ #
71
+ # @return [Hash] an hash with event names as keys and arrays of subscriptions
72
+ # as values
73
+ #
74
+ # @example Current subscriptions
75
+ # Spree::Event.listeners
76
+ # # => {"order_finalized.spree"=> [#<ActiveSupport...>],
77
+ # "reimbursement_reimbursed.spree"=> [#<ActiveSupport...>]}
78
+ def listeners
79
+ adapter.listeners_for(listener_names)
80
+ end
81
+
82
+ # The adapter used by Spree::Event, defaults to
83
+ # Spree::Event::Adapters::ActiveSupportNotifications
84
+ #
85
+ # @example Change the adapter
86
+ # Spree::Config.events.adapter = "Spree::EventBus.new"
87
+ #
88
+ # @see Spree::AppConfiguration
89
+ def adapter
90
+ Spree::Config.events.adapter
91
+ end
92
+
93
+ # The suffix used for namespacing Solidus events, defaults to
94
+ # `.spree`
95
+ #
96
+ # @see Spree::Event::Configuration#suffix
97
+ def suffix
98
+ Spree::Config.events.suffix
99
+ end
100
+
101
+ private
102
+
103
+ def name_with_suffix(name)
104
+ name.end_with?(suffix) ? name : [name, suffix].join
105
+ end
106
+
107
+ def listener_names
108
+ @listeners_names ||= Set.new
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Event
5
+ module Adapters
6
+ module ActiveSupportNotifications
7
+ extend self
8
+
9
+ def fire(event_name, opts)
10
+ ActiveSupport::Notifications.instrument event_name, opts do
11
+ yield opts if block_given?
12
+ end
13
+ end
14
+
15
+ def subscribe(event_name)
16
+ ActiveSupport::Notifications.subscribe event_name do |*args|
17
+ event = ActiveSupport::Notifications::Event.new(*args)
18
+ yield event
19
+ end
20
+ end
21
+
22
+ def unsubscribe(subscriber_or_name)
23
+ ActiveSupport::Notifications.unsubscribe(subscriber_or_name)
24
+ end
25
+
26
+ def listeners_for(names)
27
+ names.each_with_object({}) do |name, memo|
28
+ listeners = ActiveSupport::Notifications.notifier.listeners_for(name)
29
+ memo[name] = listeners if listeners.present?
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Event
5
+ class Configuration
6
+ attr_writer :adapter, :suffix
7
+
8
+ def adapter
9
+ @adapter ||= Spree::Event::Adapters::ActiveSupportNotifications
10
+ end
11
+
12
+ def suffix
13
+ @suffix ||= '.spree'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Event
5
+ module Processors
6
+ module MailerProcessor
7
+ include Spree::Event::Subscriber
8
+
9
+ event_action :order_finalized
10
+ event_action :send_reimbursement_email, event_name: :reimbursement_reimbursed
11
+
12
+ def order_finalized(event)
13
+ order = event.payload[:order]
14
+ unless order.confirmation_delivered?
15
+ Spree::Config.order_mailer_class.confirm_email(order).deliver_later
16
+ order.update_column(:confirmation_delivered, true)
17
+ end
18
+ end
19
+
20
+ def send_reimbursement_email(event)
21
+ reimbursement = event.payload[:reimbursement]
22
+ Spree::Config.reimbursement_mailer_class.reimbursement_email(reimbursement.id).deliver_later
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Event
5
+ # This module simplifies adding and removing subscriptions to {Spree::Event} events.
6
+ # Here's a complete example:
7
+ # module EmailSender
8
+ # include Spree::Event::Subscriber
9
+ #
10
+ # event_action :order_finalized
11
+ # event_action :confirm_reimbursement, event_name: :reimbursement_reimbursed
12
+ #
13
+ # def order_finalized(event)
14
+ # Mailer.send_email(event.payload[:order])
15
+ # end
16
+ #
17
+ # def confirm_reimbursement(event)
18
+ # Mailer.send_email(event.payload[:reimbursement])
19
+ # end
20
+ # end
21
+ #
22
+ # EmailSender.subscribe!
23
+ module Subscriber
24
+ def self.included(base)
25
+ base.extend base
26
+
27
+ base.mattr_accessor :event_actions
28
+ base.event_actions = {}
29
+ end
30
+
31
+ # Declares a method name in the including module that can be subscribed/unsubscribed
32
+ # to an event.
33
+ #
34
+ # @param method_name [String, Symbol] the method that will be called when the subscribed event is fired
35
+ # @param event_name [String, Symbol] the name of the event to be subscribed
36
+ #
37
+ # @example Declares 'send_email' as an event action that can subscribe the event 'order_finalized'
38
+ # module EmailSender
39
+ # event_action :send_email, event_name: :order_finalized
40
+ #
41
+ # def send_email(event)
42
+ # Mailer.send_email(event.payload[:order])
43
+ # end
44
+ # end
45
+ #
46
+ # @example Same as above, but the method name is same as the event name:
47
+ # module EmailSender
48
+ # event_action :order_completed
49
+ #
50
+ # def order_completed(event)
51
+ # Mailer.send_email(event.payload[:order])
52
+ # end
53
+ # end
54
+ def event_action(method_name, event_name: nil)
55
+ mattr_accessor "#{method_name}_handler"
56
+ event_actions[method_name] = (event_name || method_name).to_s
57
+ end
58
+
59
+ # Subscribes all declared event actions to their events. Only actions that are subscribed
60
+ # will be called when their event fires.
61
+ #
62
+ # @example subscribe all event actions for module 'EmailSender'
63
+ # EmailSender.subscribe!
64
+ def subscribe!
65
+ unsubscribe!
66
+ event_actions.each do |event_action, event_name|
67
+ send "#{event_action}_handler=", Spree::Event.subscribe(event_name) { |event|
68
+ send event_action, event
69
+ }
70
+ end
71
+ end
72
+
73
+ # Unsubscribes all declared event actions from their events. This means that when an event
74
+ # fires then none of its unsubscribed event actions will be called.
75
+ # @example unsubscribe all event actions for module 'EmailSender'
76
+ # EmailSender.unsubscribe!
77
+ def unsubscribe!
78
+ event_actions.keys.each do |event_action|
79
+ Spree::Event.unsubscribe send("#{event_action}_handler")
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -8,10 +8,7 @@ module Spree
8
8
  ATTRIBUTES = [
9
9
  :address_attributes,
10
10
  :address_book_attributes,
11
- :checkout_address_attributes,
12
- :checkout_delivery_attributes,
13
- :checkout_payment_attributes,
14
- :checkout_confirm_attributes,
11
+ :checkout_attributes,
15
12
  :credit_card_update_attributes,
16
13
  :customer_return_attributes,
17
14
  :image_attributes,
@@ -48,6 +45,10 @@ module Spree
48
45
 
49
46
  @@address_book_attributes = address_attributes + [:default]
50
47
 
48
+ @@checkout_attributes = [
49
+ :coupon_code, :email, :special_instructions, :use_billing
50
+ ]
51
+
51
52
  @@credit_card_update_attributes = [
52
53
  :month, :year, :expiry, :first_name, :last_name, :name
53
54
  ]
@@ -78,7 +79,7 @@ module Spree
78
79
 
79
80
  @@property_attributes = [:name, :presentation]
80
81
 
81
- @@return_authorization_attributes = [:memo, :stock_location_id, :return_reason_id, return_items_attributes: [:inventory_unit_id, :exchange_variant_id, :return_reason_id]]
82
+ @@return_authorization_attributes = [:memo, :stock_location_id, :return_reason_id, return_items_attributes: [:inventory_unit_id, :exchange_variant_id, :return_reason_id, :preferred_reimbursement_type_id]]
82
83
 
83
84
  @@shipment_attributes = [
84
85
  :special_instructions, :stock_location_id, :id, :tracking,
@@ -90,7 +91,7 @@ module Spree
90
91
  :number, :month, :year, :expiry, :verification_value,
91
92
  :first_name, :last_name, :cc_type, :gateway_customer_profile_id,
92
93
  :gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
93
- :existing_card_id, :wallet_payment_source_id, address_attributes: address_attributes
94
+ :existing_card_id, :wallet_payment_source_id
94
95
  ]
95
96
 
96
97
  @@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
@@ -128,75 +129,5 @@ module Spree
128
129
  :product_id, :product, :option_values_attributes, :price,
129
130
  :weight, :height, :width, :depth, :sku, :cost_currency, option_value_ids: [], options: [:name, :value]
130
131
  ]
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
201
132
  end
202
133
  end