solidus_core 2.11.16 → 3.0.0.rc2
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/assets/javascripts/spree.js.erb +0 -51
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -13
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -2
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +0 -37
- data/app/models/concerns/spree/user_methods.rb +2 -11
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -187
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +12 -48
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -11
- data/app/models/spree/country.rb +1 -6
- data/app/models/spree/credit_card.rb +0 -27
- data/app/models/spree/customer_return.rb +1 -4
- data/app/models/spree/image/active_storage_attachment.rb +2 -10
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +2 -45
- data/app/models/spree/order.rb +4 -137
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_shipping.rb +9 -6
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +9 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
- data/app/models/spree/payment_method.rb +2 -106
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -39
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/rules/taxon.rb +2 -15
- data/app/models/spree/promotion.rb +2 -6
- data/app/models/spree/promotion_action.rb +2 -12
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +2 -2
- data/app/models/spree/promotion_rule.rb +0 -4
- data/app/models/spree/refund.rb +0 -60
- data/app/models/spree/reimbursement.rb +3 -41
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +1 -4
- data/app/models/spree/return_item.rb +1 -19
- data/app/models/spree/shipment.rb +1 -54
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/simple_coordinator.rb +1 -20
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +0 -8
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
- data/app/models/spree/tax_rate.rb +0 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- data/app/models/spree/taxon.rb +0 -11
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +2 -46
- data/config/locales/en.yml +0 -8
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +13 -2
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +6 -73
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -14
- data/lib/spree/core/controller_helpers/order.rb +2 -22
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +0 -43
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +0 -40
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +0 -26
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +9 -8
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +3 -1
- data/lib/spree/event.rb +0 -31
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +3 -60
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +6 -16
- data/lib/spree/testing_support/factories/order_factory.rb +0 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support.rb +1 -1
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +20 -15
- data/solidus_core.gemspec +1 -24
- metadata +9 -74
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/preferences/persistable.rb +0 -23
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/spree/testing_support/fixtures/file.txt +0 -1
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
@@ -68,17 +68,8 @@ module Spree
|
|
68
68
|
|
69
69
|
def order
|
70
70
|
@order ||= begin
|
71
|
-
|
72
|
-
|
73
|
-
"Spree::Order state machine defined in Spree::Order::Checkout is deprecated. " \
|
74
|
-
"Future versions of Solidus will use Spree::Core::StateMachines::Order}",
|
75
|
-
caller
|
76
|
-
)
|
77
|
-
'Spree::Order::Checkout'
|
78
|
-
else
|
79
|
-
require 'spree/core/state_machines/order'
|
80
|
-
'Spree::Core::StateMachines::Order'
|
81
|
-
end
|
71
|
+
require 'spree/core/state_machines/order'
|
72
|
+
'Spree::Core::StateMachines::Order'
|
82
73
|
end
|
83
74
|
|
84
75
|
@order.constantize
|
@@ -12,7 +12,7 @@ module Spree
|
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
class EmailValidator < ActiveModel::EachValidator
|
15
|
-
EMAIL_REGEXP =
|
15
|
+
EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
|
16
16
|
|
17
17
|
def validate_each(record, attribute, value)
|
18
18
|
unless EMAIL_REGEXP.match? value
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "action_mailer/railtie"
|
5
|
+
require "action_view/railtie"
|
6
|
+
require "active_job/railtie"
|
7
|
+
require "active_model/railtie"
|
8
|
+
require "active_record/railtie"
|
9
|
+
require "active_storage/engine"
|
10
|
+
require "sprockets/railtie"
|
11
|
+
|
4
12
|
require 'acts_as_list'
|
5
13
|
require 'awesome_nested_set'
|
6
14
|
require 'cancan'
|
@@ -9,12 +17,10 @@ require 'kaminari/activerecord'
|
|
9
17
|
require 'mail'
|
10
18
|
require 'monetize'
|
11
19
|
require 'paperclip'
|
12
|
-
require 'paranoia'
|
13
20
|
require 'ransack'
|
14
21
|
require 'state_machines-activerecord'
|
15
22
|
|
16
23
|
require 'spree/deprecation'
|
17
|
-
require 'spree/paranoia_deprecations'
|
18
24
|
|
19
25
|
# This is required because ActiveModel::Validations#invalid? conflicts with the
|
20
26
|
# invalid state of a Payment. In the future this should be removed.
|
@@ -47,9 +53,6 @@ module Spree
|
|
47
53
|
|
48
54
|
module Core
|
49
55
|
class GatewayError < RuntimeError; end
|
50
|
-
|
51
|
-
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
52
|
-
deprecate_constant 'DestroyWithOrdersError', ActiveRecord::DeleteRestrictionError, deprecator: Spree::Deprecation
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
@@ -61,7 +64,6 @@ require 'spree/core/environment_extension'
|
|
61
64
|
require 'spree/core/environment/calculators'
|
62
65
|
require 'spree/core/environment/promotions'
|
63
66
|
require 'spree/core/environment'
|
64
|
-
require 'spree/promo/environment'
|
65
67
|
require 'spree/migrations'
|
66
68
|
require 'spree/migration_helpers'
|
67
69
|
require 'spree/event'
|
@@ -75,7 +77,6 @@ require 'spree/permitted_attributes'
|
|
75
77
|
require 'spree/core/importer'
|
76
78
|
require 'spree/core/permalinks'
|
77
79
|
require 'spree/core/product_duplicator'
|
78
|
-
require 'spree/core/current_store'
|
79
80
|
require 'spree/core/controller_helpers/auth'
|
80
81
|
require 'spree/core/controller_helpers/common'
|
81
82
|
require 'spree/core/controller_helpers/current_host'
|
@@ -7,11 +7,6 @@ module Spree
|
|
7
7
|
@subscriber_registry ||= Spree::Event::SubscriberRegistry.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def subscribers
|
11
|
-
Spree::Deprecation.warn("`Spree::Config.events.subscribers` is deprecated. Please use `Spree::Config.events.subscriber_registry`.", caller)
|
12
|
-
subscriber_registry.send(:registry).keys.map { |module_name| module_name.constantize }
|
13
|
-
end
|
14
|
-
|
15
10
|
attr_writer :adapter, :suffix, :autoload_subscribers
|
16
11
|
|
17
12
|
def autoload_subscribers
|
@@ -59,14 +59,6 @@ module Spree
|
|
59
59
|
# end
|
60
60
|
# end
|
61
61
|
def event_action(method_name, event_name: nil)
|
62
|
-
mattr_writer "#{method_name}_handler"
|
63
|
-
|
64
|
-
define_method "#{method_name}_handler" do
|
65
|
-
Spree::Deprecation.warn("#{name}.#{method_name}_handler and #{name}.#{method_name}_handler= from the old events mapping interface are deprecated. Please use the new mapping stored in Spree::Event.subscribers.", caller)
|
66
|
-
|
67
|
-
class_variable_get("@@#{method_name}_handler")
|
68
|
-
end
|
69
|
-
|
70
62
|
event_actions[method_name] = (event_name || method_name).to_s
|
71
63
|
end
|
72
64
|
|
@@ -89,16 +81,6 @@ module Spree
|
|
89
81
|
def deactivate(event_action_name = nil)
|
90
82
|
Spree::Event.subscriber_registry.deactivate_subscriber(self, event_action_name)
|
91
83
|
end
|
92
|
-
|
93
|
-
def subscribe!
|
94
|
-
Spree::Deprecation.warn("#{self}.subscribe! is deprecated. Please use `#{self}.activate`.", caller)
|
95
|
-
activate
|
96
|
-
end
|
97
|
-
|
98
|
-
def unsubscribe!
|
99
|
-
Spree::Deprecation.warn("#{self}.unsubscribe! is deprecated. Please use `#{self}.deactivate`.", caller)
|
100
|
-
deactivate
|
101
|
-
end
|
102
84
|
end
|
103
85
|
end
|
104
86
|
end
|
@@ -35,7 +35,9 @@ module Spree
|
|
35
35
|
subscription = Spree::Event.subscribe(event_name) { |event| subscriber.send(event_action, event) }
|
36
36
|
|
37
37
|
# deprecated mappings, to be removed when Solidus 2.10 is not supported anymore:
|
38
|
-
subscriber.
|
38
|
+
if subscriber.respond_to?("#{event_action}_handler=")
|
39
|
+
subscriber.send("#{event_action}_handler=", subscription)
|
40
|
+
end
|
39
41
|
|
40
42
|
registry[subscriber.name][event_action] = subscription
|
41
43
|
end
|
data/lib/spree/event.rb
CHANGED
@@ -29,20 +29,6 @@ module Spree
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
# @deprecated Loads all Solidus' core and application's event subscribers files.
|
33
|
-
# The latter are loaded automatically only when the preference
|
34
|
-
# Spree::Config.events.autoload_subscribers is set to a truthy value.
|
35
|
-
#
|
36
|
-
# Files must be placed under the directory `app/subscribers` and their
|
37
|
-
# name must end with `_subscriber.rb`.
|
38
|
-
#
|
39
|
-
# Loading the files has the side effect of adding their module to the
|
40
|
-
# list in Spree::Event.subscribers.
|
41
|
-
def require_subscriber_files
|
42
|
-
Spree::Deprecation.warn("#{self}.require_subscriber_files is deprecated and will be removed in Solidus 3.0.", caller)
|
43
|
-
subscriber_registry.send(:require_subscriber_files)
|
44
|
-
end
|
45
|
-
|
46
32
|
# Subscribe to an event with the given name. The provided block is executed
|
47
33
|
# every time the subscribed event is fired.
|
48
34
|
#
|
@@ -114,23 +100,6 @@ module Spree
|
|
114
100
|
Spree::Config.events.adapter
|
115
101
|
end
|
116
102
|
|
117
|
-
# The suffix used for namespacing Solidus events, defaults to
|
118
|
-
# `.spree`
|
119
|
-
#
|
120
|
-
# @see Spree::Event::Configuration#suffix
|
121
|
-
def suffix
|
122
|
-
Spree::Deprecation.warn "This method is deprecated and will be removed. Please use Event::Adapters::ActiveSupportNotifications#suffix"
|
123
|
-
Spree::Config.events.suffix
|
124
|
-
end
|
125
|
-
|
126
|
-
# @deprecated
|
127
|
-
# @!attribute [r] subscribers
|
128
|
-
# @return [Array<Spree::Event::Subscriber>] A list of subscribers used to support class reloading for Spree::Event::Subscriber instances
|
129
|
-
def subscribers
|
130
|
-
Spree::Deprecation.warn("`#{self}.subscribers` is deprecated. Please use `#{self}.subscriber_registry` instead.", caller)
|
131
|
-
Spree::Config.events.subscribers
|
132
|
-
end
|
133
|
-
|
134
103
|
# @!attribute [r] subscribers
|
135
104
|
# @return <Spree::Event::SubscriberRegistry> The registry for supporting class reloading for Spree::Event::Subscriber instances
|
136
105
|
def subscriber_registry
|
data/lib/spree/i18n.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'i18n'
|
4
|
-
require 'active_support/core_ext/array/extract_options'
|
5
|
-
require 'action_view'
|
6
4
|
|
7
5
|
module Spree
|
8
6
|
def self.i18n_available_locales
|
@@ -11,29 +9,9 @@ module Spree
|
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
|
-
class TranslationHelperWrapper # :nodoc:
|
15
|
-
include ActionView::Helpers::TranslationHelper
|
16
|
-
end
|
17
|
-
|
18
12
|
# This value is used as a count for the pluralization helpers related to I18n
|
19
13
|
# ex: Spree::Order.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
|
20
14
|
# Related to Solidus issue #1164, this is needed to avoid problems with
|
21
15
|
# some pluralization calculators
|
22
16
|
I18N_GENERIC_PLURAL = 2.1
|
23
|
-
|
24
|
-
class << self
|
25
|
-
# Add spree namespace and delegate to Rails TranslationHelper for some nice
|
26
|
-
# extra functionality. e.g return reasonable strings for missing translations
|
27
|
-
|
28
|
-
def translate(key, options = {})
|
29
|
-
Spree::Deprecation.warn <<-WARN.squish
|
30
|
-
Spree.t & Spree.translate have been deprecated.
|
31
|
-
Instead use I18n.t('spree.your_translation_key')
|
32
|
-
WARN
|
33
|
-
options[:scope] = [:spree, *options[:scope]]
|
34
|
-
TranslationHelperWrapper.new.translate(key, **options)
|
35
|
-
end
|
36
|
-
|
37
|
-
alias_method :t, :translate
|
38
|
-
end
|
39
17
|
end
|
data/lib/spree/money.rb
CHANGED
@@ -6,7 +6,6 @@ module Spree
|
|
6
6
|
class Money
|
7
7
|
include Comparable
|
8
8
|
DifferentCurrencyError = Class.new(StandardError)
|
9
|
-
RUBY_NUMERIC_STRING = /\A-?\d+(\.\d+)?\z/
|
10
9
|
|
11
10
|
class <<self
|
12
11
|
attr_accessor :default_formatting_rules
|
@@ -37,15 +36,8 @@ module Spree
|
|
37
36
|
@money = amount
|
38
37
|
else
|
39
38
|
currency = (options[:currency] || Spree::Config[:currency])
|
40
|
-
|
41
|
-
|
42
|
-
else
|
43
|
-
@money = Spree::Money.parse_to_money(amount, currency)
|
44
|
-
Spree::Deprecation.warn <<-WARN.squish, caller
|
45
|
-
Spree::Money was initialized with #{amount.inspect}, which will not be supported in the future.
|
46
|
-
Instead use Spree::Money.new(#{@money.to_s.inspect}, options) or Spree::Money.parse(#{amount.inspect})
|
47
|
-
WARN
|
48
|
-
end
|
39
|
+
|
40
|
+
@money = Monetize.from_string(amount, currency)
|
49
41
|
end
|
50
42
|
@options = Spree::Money.default_formatting_rules.merge(options)
|
51
43
|
end
|
@@ -80,14 +72,7 @@ module Spree
|
|
80
72
|
def to_html(options = { html_wrap: true })
|
81
73
|
output = format(options)
|
82
74
|
# Maintain compatibility by checking html option renamed to html_wrap.
|
83
|
-
if options[:
|
84
|
-
Spree::Deprecation.warn <<-WARN.squish, caller
|
85
|
-
Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html].inspect}),
|
86
|
-
which will not be supported in the future.
|
87
|
-
Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html].inspect})
|
88
|
-
WARN
|
89
|
-
end
|
90
|
-
if options[:html_wrap] || options[:html]
|
75
|
+
if options[:html_wrap]
|
91
76
|
output = output.html_safe
|
92
77
|
end
|
93
78
|
output
|
@@ -39,8 +39,7 @@ module Spree
|
|
39
39
|
mattr_reader(*ATTRIBUTES)
|
40
40
|
|
41
41
|
@@address_attributes = [
|
42
|
-
:id, :name, :
|
43
|
-
:address1, :address2, :city, :country_id, :state_id,
|
42
|
+
:id, :name, :address1, :address2, :city, :country_id, :state_id,
|
44
43
|
:zipcode, :phone, :state_name, :country_iso, :alternative_phone, :company,
|
45
44
|
country: [:iso, :name, :iso3, :iso_name],
|
46
45
|
state: [:name, :abbr]
|
@@ -52,13 +51,7 @@ module Spree
|
|
52
51
|
:month, :year, :expiry, :first_name, :last_name, :name
|
53
52
|
]
|
54
53
|
|
55
|
-
@@customer_return_attributes = [
|
56
|
-
:stock_location_id, return_items_attributes: [
|
57
|
-
:id, :inventory_unit_id, :return_authorization_id, :returned, :amount,
|
58
|
-
:reception_status_event, :acceptance_status, :exchange_variant_id,
|
59
|
-
:resellable, :return_reason_id
|
60
|
-
]
|
61
|
-
]
|
54
|
+
@@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :amount, :reception_status_event, :acceptance_status, :exchange_variant_id, :resellable]]
|
62
55
|
|
63
56
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
64
57
|
|
@@ -96,7 +89,7 @@ module Spree
|
|
96
89
|
:number, :month, :year, :expiry, :verification_value,
|
97
90
|
:first_name, :last_name, :cc_type, :gateway_customer_profile_id,
|
98
91
|
:gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
|
99
|
-
:
|
92
|
+
:wallet_payment_source_id, address_attributes: address_attributes
|
100
93
|
]
|
101
94
|
|
102
95
|
@@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
|
@@ -149,61 +142,11 @@ module Spree
|
|
149
142
|
]
|
150
143
|
|
151
144
|
@@checkout_payment_attributes = [
|
152
|
-
:coupon_code,
|
153
145
|
payments_attributes: payment_attributes + [
|
154
146
|
source_attributes: source_attributes
|
155
147
|
]
|
156
148
|
]
|
157
149
|
|
158
150
|
@@checkout_confirm_attributes = []
|
159
|
-
|
160
|
-
def self.checkout_attributes
|
161
|
-
Spree::Deprecation.warn <<-WARN.squish, caller
|
162
|
-
checkout_attributes is deprecated, please use the permitted
|
163
|
-
attributes set for the specific step that needs to be updated.
|
164
|
-
|
165
|
-
E.g. permitted_checkout_address_attributes
|
166
|
-
WARN
|
167
|
-
|
168
|
-
CheckoutAdditionalAttributes.new(
|
169
|
-
checkout_address_attributes +
|
170
|
-
checkout_delivery_attributes +
|
171
|
-
checkout_payment_attributes +
|
172
|
-
checkout_confirm_attributes
|
173
|
-
)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
class CheckoutAdditionalAttributes < Array
|
178
|
-
def <<(*attributes)
|
179
|
-
super
|
180
|
-
|
181
|
-
inject_attributes_to_all_steps(attributes, :<<)
|
182
|
-
end
|
183
|
-
|
184
|
-
def push(*attributes)
|
185
|
-
super
|
186
|
-
|
187
|
-
inject_attributes_to_all_steps(attributes, :push)
|
188
|
-
end
|
189
|
-
alias append push
|
190
|
-
|
191
|
-
def prepend(*attributes)
|
192
|
-
super
|
193
|
-
|
194
|
-
inject_attributes_to_all_steps(attributes, :prepend)
|
195
|
-
end
|
196
|
-
alias unshift prepend
|
197
|
-
|
198
|
-
private
|
199
|
-
|
200
|
-
def inject_attributes_to_all_steps(attributes, method_name)
|
201
|
-
attributes.each do |attribute|
|
202
|
-
PermittedAttributes.checkout_address_attributes.send(method_name, attribute)
|
203
|
-
PermittedAttributes.checkout_delivery_attributes.send(method_name, attribute)
|
204
|
-
PermittedAttributes.checkout_payment_attributes.send(method_name, attribute)
|
205
|
-
PermittedAttributes.checkout_confirm_attributes.send(method_name, attribute)
|
206
|
-
end
|
207
|
-
end
|
208
151
|
end
|
209
152
|
end
|
@@ -35,18 +35,6 @@ module Spree
|
|
35
35
|
find("td:nth-of-type(#{num})").text
|
36
36
|
end
|
37
37
|
|
38
|
-
def fill_in_quantity(table_column, selector, quantity)
|
39
|
-
Spree::Deprecation.warn <<-WARN.strip_heredoc
|
40
|
-
fill_in_quantity is deprecated. Instead use:
|
41
|
-
within(#{table_column.inspect}) do
|
42
|
-
fill_in #{selector.inspect}, with: #{quantity.inspect}
|
43
|
-
end
|
44
|
-
WARN
|
45
|
-
within(table_column) do
|
46
|
-
fill_in selector, with: quantity
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
38
|
def select2_search(value, options)
|
51
39
|
options = {
|
52
40
|
search: value, # by default search for the value
|
@@ -122,21 +110,6 @@ module Spree
|
|
122
110
|
# find the original.
|
123
111
|
find('label:not(.select2-offscreen)', text: /#{Regexp.escape(text)}/i, match: :one)
|
124
112
|
end
|
125
|
-
|
126
|
-
def wait_for_ajax
|
127
|
-
Spree::Deprecation.warn <<-WARN.squish, caller
|
128
|
-
wait_for_ajax has been deprecated.
|
129
|
-
Please refer to the capybara documentation on how to properly wait for asyncronous behavior:
|
130
|
-
https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends
|
131
|
-
WARN
|
132
|
-
|
133
|
-
counter = 0
|
134
|
-
while page.evaluate_script("typeof($) === 'undefined' || $.active > 0")
|
135
|
-
counter += 1
|
136
|
-
sleep(0.1)
|
137
|
-
raise "AJAX request took longer than 5 seconds." if counter >= 50
|
138
|
-
end
|
139
|
-
end
|
140
113
|
end
|
141
114
|
end
|
142
115
|
end
|
@@ -156,9 +129,6 @@ RSpec::Matchers.define :have_meta do |name, expected|
|
|
156
129
|
end
|
157
130
|
end
|
158
131
|
|
159
|
-
# @private
|
160
|
-
CapybaraExt = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('CapybaraExt', 'Spree::TestingSupport::CapybaraExt')
|
161
|
-
|
162
132
|
RSpec.configure do |c|
|
163
133
|
c.include Spree::TestingSupport::CapybaraExt
|
164
134
|
end
|
@@ -2,23 +2,12 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module TestingSupport
|
5
|
-
# A module providing convenience methods to test Solidus controllers
|
6
|
-
# in Rails controller/functional tests. Possibly from inside an
|
7
|
-
# application with a mounted Solidus engine.
|
8
|
-
#
|
9
5
|
# *There is generaly no need* to use this module. Instead, in
|
10
6
|
# a functional/controller test against a Spree controller, just
|
11
7
|
# use standard Rails functionality by including:
|
12
8
|
#
|
13
9
|
# routes { Spree::Core::Engine.routes }
|
14
10
|
#
|
15
|
-
# And then use standard Rails test `get`, `post` etc methods.
|
16
|
-
#
|
17
|
-
# But some legacy code uses this ControllerRequests helper. It must
|
18
|
-
# be included only in tests against Spree controllers, it will interfere
|
19
|
-
# with tests against local app or other engine controllers, resulting
|
20
|
-
# in ActionController::UrlGenerationError.
|
21
|
-
#
|
22
11
|
# To use this module, inside your spec_helper.rb, include this module inside
|
23
12
|
# the RSpec.configure block by:
|
24
13
|
#
|
@@ -26,83 +15,12 @@ module Spree
|
|
26
15
|
# RSpec.configure do |c|
|
27
16
|
# c.include Spree::TestingSupport::ControllerRequests, spree_controller: true
|
28
17
|
# end
|
29
|
-
#
|
30
|
-
# Then, in your controller tests against spree controllers, you can access
|
31
|
-
# tag to use this module, and access spree routes like this:
|
32
|
-
#
|
33
|
-
# require 'spec_helper'
|
34
|
-
#
|
35
|
-
# describe Spree::ProductsController, :spree_controller do
|
36
|
-
# it "can see all the products" do
|
37
|
-
# spree_get :index
|
38
|
-
# end
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# Use spree_get, spree_post, spree_put or spree_delete to make requests to
|
42
|
-
# the Spree engine, and use regular get, post, put or delete to make
|
43
|
-
# requests to your application.
|
44
18
|
module ControllerRequests
|
45
19
|
extend ActiveSupport::Concern
|
46
20
|
|
47
21
|
included do
|
48
22
|
routes { Spree::Core::Engine.routes }
|
49
23
|
end
|
50
|
-
|
51
|
-
def spree_get(action, parameters = nil, session = nil, flash = nil)
|
52
|
-
process_spree_action(action, parameters, session, flash, "GET")
|
53
|
-
end
|
54
|
-
deprecate spree_get: :get, deprecator: Spree::Deprecation
|
55
|
-
|
56
|
-
# Executes a request simulating POST HTTP method and set/volley the response
|
57
|
-
def spree_post(action, parameters = nil, session = nil, flash = nil)
|
58
|
-
process_spree_action(action, parameters, session, flash, "POST")
|
59
|
-
end
|
60
|
-
deprecate spree_post: :post, deprecator: Spree::Deprecation
|
61
|
-
|
62
|
-
# Executes a request simulating PUT HTTP method and set/volley the response
|
63
|
-
def spree_put(action, parameters = nil, session = nil, flash = nil)
|
64
|
-
process_spree_action(action, parameters, session, flash, "PUT")
|
65
|
-
end
|
66
|
-
deprecate spree_put: :put, deprecator: Spree::Deprecation
|
67
|
-
|
68
|
-
# Executes a request simulating DELETE HTTP method and set/volley the response
|
69
|
-
def spree_delete(action, parameters = nil, session = nil, flash = nil)
|
70
|
-
process_spree_action(action, parameters, session, flash, "DELETE")
|
71
|
-
end
|
72
|
-
deprecate spree_delete: :delete, deprecator: Spree::Deprecation
|
73
|
-
|
74
|
-
def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
|
75
|
-
process_spree_xhr_action(action, parameters, session, flash, :get)
|
76
|
-
end
|
77
|
-
deprecate spree_xhr_get: :get, deprecator: Spree::Deprecation
|
78
|
-
|
79
|
-
def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
|
80
|
-
process_spree_xhr_action(action, parameters, session, flash, :post)
|
81
|
-
end
|
82
|
-
deprecate spree_xhr_post: :post, deprecator: Spree::Deprecation
|
83
|
-
|
84
|
-
def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
|
85
|
-
process_spree_xhr_action(action, parameters, session, flash, :put)
|
86
|
-
end
|
87
|
-
deprecate spree_xhr_put: :put, deprecator: Spree::Deprecation
|
88
|
-
|
89
|
-
def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
|
90
|
-
process_spree_xhr_action(action, parameters, session, flash, :delete)
|
91
|
-
end
|
92
|
-
deprecate spree_xhr_delete: :delete, deprecator: Spree::Deprecation
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
97
|
-
parameters ||= {}
|
98
|
-
process(action, method, parameters, session, flash)
|
99
|
-
end
|
100
|
-
|
101
|
-
def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
|
102
|
-
parameters ||= {}
|
103
|
-
parameters.reverse_merge!(format: :json)
|
104
|
-
xml_http_request(method, action, parameters, session, flash)
|
105
|
-
end
|
106
24
|
end
|
107
25
|
end
|
108
26
|
end
|
@@ -27,9 +27,6 @@ module DummyApp
|
|
27
27
|
ActiveRecord::Base.remove_connection
|
28
28
|
|
29
29
|
sh 'rake db:reset VERBOSE=false'
|
30
|
-
if ENV['ENABLE_ACTIVE_STORAGE']
|
31
|
-
sh 'rake active_storage:install db:migrate VERBOSE=false'
|
32
|
-
end
|
33
30
|
|
34
31
|
# We have a brand new database, so we must re-establish our connection
|
35
32
|
ActiveRecord::Base.establish_connection
|
@@ -7,6 +7,7 @@ require 'rails'
|
|
7
7
|
require 'active_record/railtie'
|
8
8
|
require 'action_controller/railtie'
|
9
9
|
require 'action_mailer/railtie'
|
10
|
+
require 'active_storage/engine'
|
10
11
|
|
11
12
|
Rails.env = 'test'
|
12
13
|
|
@@ -45,7 +46,6 @@ module DummyApp
|
|
45
46
|
end
|
46
47
|
|
47
48
|
class Application < ::Rails::Application
|
48
|
-
config.has_many_inverse = true
|
49
49
|
config.eager_load = false
|
50
50
|
config.cache_classes = true
|
51
51
|
config.cache_store = :memory_store
|
@@ -68,7 +68,7 @@ module DummyApp
|
|
68
68
|
|
69
69
|
config.storage_path = Rails.root.join('tmp', 'storage')
|
70
70
|
|
71
|
-
|
71
|
+
unless ENV['DISABLE_ACTIVE_STORAGE']
|
72
72
|
initializer 'solidus.active_storage' do
|
73
73
|
config.active_storage.service_configurations = {
|
74
74
|
test: {
|
@@ -77,7 +77,6 @@ module DummyApp
|
|
77
77
|
}
|
78
78
|
}
|
79
79
|
config.active_storage.service = :test
|
80
|
-
config.active_storage.variant_processor = ENV.fetch('ACTIVE_STORAGE_VARIANT_PROCESSOR', :mini_magick).to_sym
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
@@ -118,20 +117,11 @@ end
|
|
118
117
|
|
119
118
|
Spree.user_class = 'Spree::LegacyUser'
|
120
119
|
Spree.config do |config|
|
121
|
-
config.use_legacy_address_state_validator = false
|
122
120
|
config.mails_from = "store@example.com"
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
config.use_legacy_order_state_machine = false
|
128
|
-
config.use_custom_cancancan_actions = false
|
129
|
-
config.consider_actionless_promotion_active = false
|
130
|
-
config.use_legacy_store_credit_reimbursement_category_name = false
|
131
|
-
|
132
|
-
if ENV['ENABLE_ACTIVE_STORAGE']
|
133
|
-
config.image_attachment_module = 'Spree::Image::ActiveStorageAttachment'
|
134
|
-
config.taxon_attachment_module = 'Spree::Taxon::ActiveStorageAttachment'
|
121
|
+
|
122
|
+
if ENV['DISABLE_ACTIVE_STORAGE']
|
123
|
+
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
|
124
|
+
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
|
135
125
|
end
|
136
126
|
end
|
137
127
|
|
@@ -1,33 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spree/deprecation'
|
4
|
-
|
5
3
|
module Spree
|
6
4
|
module TestingSupport
|
7
5
|
module Preferences
|
8
|
-
# Resets all preferences to default values, you can
|
9
|
-
# pass a block to override the defaults with a block
|
10
|
-
#
|
11
|
-
# reset_spree_preferences do |config|
|
12
|
-
# config.track_inventory_levels = false
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# @deprecated
|
16
|
-
def reset_spree_preferences(&config_block)
|
17
|
-
Spree::Config.instance_variables.
|
18
|
-
reject { |iv| iv == :@events_configuration }.
|
19
|
-
each { |iv| Spree::Config.remove_instance_variable(iv) }
|
20
|
-
Spree::Config.preference_store = Spree::Config.default_preferences
|
21
|
-
|
22
|
-
if defined?(Railties)
|
23
|
-
Rails.application.config.spree = Spree::Config.environment
|
24
|
-
end
|
25
|
-
|
26
|
-
configure_spree_preferences(&config_block) if block_given?
|
27
|
-
end
|
28
|
-
|
29
|
-
deprecate :reset_spree_preferences, deprecator: Spree::Deprecation
|
30
|
-
|
31
6
|
def configure_spree_preferences
|
32
7
|
yield(Spree::Config) if block_given?
|
33
8
|
end
|