spree_core 4.2.0.rc1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree.js +16 -0
- data/app/controllers/spree/base_controller.rb +2 -3
- data/app/controllers/spree/errors_controller.rb +11 -0
- data/app/finders/spree/addresses/find.rb +1 -12
- data/app/finders/spree/base_finder.rb +14 -0
- data/app/finders/spree/countries/find.rb +11 -3
- data/app/finders/spree/credit_cards/find.rb +2 -2
- data/app/finders/spree/orders/find_current.rb +2 -2
- data/app/finders/spree/products/find.rb +14 -3
- data/app/helpers/spree/base_helper.rb +4 -9
- data/app/helpers/spree/currency_helper.rb +24 -0
- data/app/helpers/spree/locale_helper.rb +31 -0
- data/app/helpers/spree/products_helper.rb +37 -12
- data/app/mailers/spree/base_mailer.rb +4 -4
- data/app/mailers/spree/order_mailer.rb +3 -3
- data/app/mailers/spree/reimbursement_mailer.rb +1 -1
- data/app/mailers/spree/shipment_mailer.rb +1 -1
- data/app/models/concerns/spree/default_price.rb +1 -5
- data/app/models/concerns/spree/product_scopes.rb +1 -1
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/concerns/spree/user_payment_source.rb +1 -1
- data/app/models/spree/ability.rb +45 -34
- data/app/models/spree/address.rb +4 -0
- data/app/models/spree/adjustment.rb +1 -0
- data/app/models/spree/app_configuration.rb +2 -3
- data/app/models/spree/app_dependencies.rb +6 -2
- data/app/models/spree/base.rb +5 -0
- data/app/models/spree/credit_card.rb +4 -0
- data/app/models/spree/fulfilment_changer.rb +58 -16
- data/app/models/spree/image.rb +14 -14
- data/app/models/spree/inventory_unit.rb +2 -7
- data/app/models/spree/line_item.rb +7 -15
- data/app/models/spree/log_entry.rb +1 -1
- data/app/models/spree/option_type.rb +2 -0
- data/app/models/spree/order.rb +5 -4
- data/app/models/spree/order/address_book.rb +7 -20
- data/app/models/spree/payment.rb +18 -4
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/payment_method.rb +3 -3
- data/app/models/spree/price.rb +2 -7
- data/app/models/spree/product.rb +41 -17
- data/app/models/spree/promotion.rb +4 -15
- data/app/models/spree/promotion/rules/option_value.rb +1 -1
- data/app/models/spree/promotion/rules/product.rb +2 -1
- data/app/models/spree/promotion/rules/user.rb +2 -1
- data/app/models/spree/promotion_handler/coupon.rb +1 -2
- data/app/models/spree/refund.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/default.rb +0 -2
- data/app/models/spree/return_item/eligibility_validator/{r_m_a_required.rb → rma_required.rb} +0 -0
- data/app/models/spree/shipment.rb +1 -1
- data/app/models/spree/shipping_method.rb +1 -5
- data/app/models/spree/shipping_rate.rb +2 -11
- data/app/models/spree/stock/availability_validator.rb +3 -4
- data/app/models/spree/stock_item.rb +1 -5
- data/app/models/spree/store.rb +59 -1
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/variant.rb +9 -16
- data/app/models/spree/zone.rb +17 -4
- data/app/paginators/spree/shared/paginate.rb +8 -1
- data/app/presenters/spree/variant_presenter.rb +2 -5
- data/app/services/spree/account/addresses/create.rb +6 -1
- data/app/services/spree/account/addresses/{base.rb → helper.rb} +1 -3
- data/app/services/spree/account/addresses/update.rb +6 -1
- data/app/services/spree/build_localized_redirect_url.rb +101 -0
- data/app/services/spree/cart/estimate_shipping_rates.rb +1 -1
- data/app/services/spree/compare_line_items.rb +4 -2
- data/app/sorters/spree/base_sorter.rb +35 -0
- data/app/sorters/spree/orders/sort.rb +1 -37
- data/app/sorters/spree/products/sort.rb +9 -32
- data/app/validators/email_validator.rb +1 -1
- data/app/views/spree/errors/forbidden.html.erb +0 -0
- data/app/views/spree/errors/unauthorized.html.erb +0 -0
- data/app/views/spree/shared/_base_mailer_stylesheets.html.erb +13 -2
- data/app/views/spree/shared/_purchased_items_table.html.erb +15 -6
- data/app/views/spree/shared/purchased_items_table/_adjustment.html.erb +2 -2
- data/app/views/spree/shared/purchased_items_table/_line_item.html.erb +2 -2
- data/config/initializers/inflections.rb +3 -0
- data/config/initializers/rails61_fixes.rb +3 -0
- data/config/locales/en.yml +36 -63
- data/config/routes.rb +2 -1
- data/db/default/spree/stores.rb +1 -0
- data/db/default/spree/zones.rb +4 -1
- data/db/migrate/20130326175857_add_stock_location_to_rma.rb +1 -1
- data/db/migrate/20191017121054_add_supported_currencies_to_store.rb +1 -0
- data/db/migrate/20201006110150_add_checkout_zone_field_to_store.rb +12 -0
- data/db/migrate/20201012091259_add_filterable_column_to_spree_option_types.rb +10 -0
- data/db/migrate/20201127084048_add_default_country_kind_to_spree_zones.rb +5 -0
- data/db/migrate/20210112193440_remove_contact_email_from_spree_stores.rb +5 -0
- data/db/migrate/20210114182625_create_spree_payment_methods_stores.rb +10 -0
- data/db/migrate/20210114220232_migrate_data_payment_methods_stores.rb +15 -0
- data/db/migrate/20210117112551_remove_store_id_from_spree_payment_methods.rb +5 -0
- data/db/migrate/20210120142527_ensure_default_locale_in_spree_stores.rb +5 -0
- data/db/migrate/20210205211040_add_supported_locales_to_spree_stores.rb +11 -0
- data/db/migrate/20210215202602_migrate_spree_i18n_globalize_config.rb +22 -0
- data/lib/generators/spree/install/install_generator.rb +9 -6
- data/lib/spree/core.rb +2 -1
- data/lib/spree/core/controller_helpers/auth.rb +3 -1
- data/lib/spree/core/controller_helpers/common.rb +6 -8
- data/lib/spree/core/controller_helpers/currency.rb +47 -0
- data/lib/spree/core/controller_helpers/locale.rb +58 -0
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/store.rb +4 -16
- data/lib/spree/core/importer/order.rb +9 -9
- data/lib/spree/core/product_filters.rb +3 -3
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/i18n.rb +17 -19
- data/lib/spree/permitted_attributes.rb +2 -2
- data/lib/spree/service_module.rb +8 -4
- data/lib/spree/testing_support/capybara_config.rb +1 -1
- data/lib/spree/testing_support/common_rake.rb +1 -1
- data/lib/spree/testing_support/controller_requests.rb +10 -10
- data/lib/spree/testing_support/factories/promotion_factory.rb +29 -17
- data/lib/spree/testing_support/factories/shipment_factory.rb +7 -9
- data/lib/spree/testing_support/factories/stock_location_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_factory.rb +1 -0
- data/lib/spree/testing_support/factories/zone_factory.rb +16 -13
- data/lib/spree/testing_support/flatpickr_capybara.rb +101 -0
- data/lib/spree/testing_support/i18n.rb +1 -1
- data/lib/spree/testing_support/locale_helpers.rb +71 -0
- data/lib/spree/testing_support/next_instance_of.rb +38 -0
- data/lib/spree/testing_support/order_walkthrough.rb +8 -3
- data/lib/spree/testing_support/rspec_retry_config.rb +10 -0
- data/spree_core.gemspec +6 -5
- metadata +74 -27
- data/lib/generators/spree/install/templates/config/initializers/spree_storefront.rb +0 -1
- data/lib/generators/spree/install/templates/config/spree_storefront.yml +0 -67
- data/lib/spree/core/controller_helpers/currency_helpers.rb +0 -15
- data/lib/spree/i18n/base.rb +0 -17
- data/lib/spree/i18n/initializer.rb +0 -1
@@ -68,9 +68,9 @@ module Spree
|
|
68
68
|
def self.price_filter
|
69
69
|
v = Spree::Price.arel_table
|
70
70
|
conds = [[Spree.t(:under_price, price: format_price(10)), v[:amount].lteq(10)],
|
71
|
-
["#{format_price(10)} - #{format_price(15)}", v[:amount].
|
72
|
-
["#{format_price(15)} - #{format_price(18)}", v[:amount].
|
73
|
-
["#{format_price(18)} - #{format_price(20)}", v[:amount].
|
71
|
+
["#{format_price(10)} - #{format_price(15)}", v[:amount].between(10..15)],
|
72
|
+
["#{format_price(15)} - #{format_price(18)}", v[:amount].between(15..18)],
|
73
|
+
["#{format_price(18)} - #{format_price(20)}", v[:amount].between(18..20)],
|
74
74
|
[Spree.t(:or_over_price, price: format_price(20)), v[:amount].gteq(20)]]
|
75
75
|
{
|
76
76
|
name: Spree.t(:price_range),
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/i18n.rb
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
require 'i18n'
|
2
2
|
require 'active_support/core_ext/array/extract_options'
|
3
|
-
require '
|
3
|
+
require 'action_view'
|
4
4
|
|
5
5
|
module Spree
|
6
|
-
|
7
|
-
|
6
|
+
class TranslationHelperWrapper
|
7
|
+
include ActionView::Helpers::TranslationHelper
|
8
|
+
end
|
8
9
|
|
9
10
|
class << self
|
10
11
|
# Add spree namespace and delegate to Rails TranslationHelper for some nice
|
11
12
|
# extra functionality. e.g return reasonable strings for missing translations
|
12
|
-
def translate(
|
13
|
-
|
13
|
+
def translate(key, options = {})
|
14
|
+
options[:scope] = [*options[:scope]].unshift(:spree).uniq
|
14
15
|
|
15
|
-
options
|
16
|
-
options[:scope] = [*options[:scope]].unshift(:spree)
|
17
|
-
args << options
|
18
|
-
super(*args)
|
16
|
+
TranslationHelperWrapper.new.translate(key, **options)
|
19
17
|
end
|
20
18
|
|
21
|
-
|
19
|
+
def available_locales
|
20
|
+
locales_from_i18n = I18n.available_locales
|
21
|
+
locales =
|
22
|
+
if defined?(SpreeI18n)
|
23
|
+
(SpreeI18n::Locale.all << :en).map(&:to_s)
|
24
|
+
else
|
25
|
+
[Rails.application.config.i18n.default_locale, I18n.locale, :en]
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
Spree::ViewContext.context
|
28
|
+
(locales + locales_from_i18n).uniq.compact
|
25
29
|
end
|
26
30
|
|
27
|
-
|
28
|
-
if context
|
29
|
-
path = context.instance_variable_get('@virtual_path')
|
30
|
-
|
31
|
-
path&.gsub(/spree/, '')
|
32
|
-
end
|
33
|
-
end
|
31
|
+
alias t translate
|
34
32
|
end
|
35
33
|
end
|
@@ -99,9 +99,9 @@ module Spree
|
|
99
99
|
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords, :logo,
|
100
100
|
:meta_description, :default_currency, :mail_from_address,
|
101
101
|
:customer_support_email, :facebook, :twitter, :instagram,
|
102
|
-
:description, :address, :
|
102
|
+
:description, :address, :contact_phone, :supported_locales,
|
103
103
|
:default_locale, :default_country_id, :supported_currencies,
|
104
|
-
:new_order_notifications_email, :mailer_logo]
|
104
|
+
:new_order_notifications_email, :mailer_logo, :checkout_zone_id, :seo_robots]
|
105
105
|
|
106
106
|
@@store_credit_attributes = %i[amount currency category_id memo]
|
107
107
|
|
data/lib/spree/service_module.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
module ServiceModule
|
3
3
|
module Callable
|
4
|
-
def call(*args)
|
5
|
-
new.call(*args).tap do |result|
|
4
|
+
def call(*args, **kwargs)
|
5
|
+
new.call(*args, **kwargs).tap do |result|
|
6
6
|
return yield(result) if block_given?
|
7
7
|
end
|
8
8
|
end
|
@@ -47,7 +47,11 @@ module Spree
|
|
47
47
|
def call(input = nil)
|
48
48
|
input ||= {}
|
49
49
|
@_passed_input = Result.new(true, input)
|
50
|
-
result =
|
50
|
+
result = if input.is_a?(Hash)
|
51
|
+
super(**input)
|
52
|
+
else
|
53
|
+
super(input)
|
54
|
+
end
|
51
55
|
@_passed_input = result if result.is_a? Result
|
52
56
|
enforce_data_format
|
53
57
|
@_passed_input
|
@@ -71,7 +75,7 @@ module Spree
|
|
71
75
|
end
|
72
76
|
|
73
77
|
begin
|
74
|
-
@_passed_input = callable.call(
|
78
|
+
@_passed_input = callable.call(**@_passed_input.value)
|
75
79
|
rescue ArgumentError => e
|
76
80
|
if e.message.include? 'missing'
|
77
81
|
raise IncompatibleParamsPassed, "You didn't pass #{e.message} to callable '#{callable.name}'"
|
@@ -15,7 +15,7 @@ namespace :common do
|
|
15
15
|
Rails.env = 'test'
|
16
16
|
|
17
17
|
Spree::DummyGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--quiet']
|
18
|
-
Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--auto-accept', '--migrate=false', '--seed=false', '--sample=false', '--quiet', '--copy_storefront=false', "--user_class=#{args[:user_class]}"]
|
18
|
+
Spree::InstallGenerator.start ["--lib_name=#{ENV['LIB_NAME']}", '--auto-accept', '--migrate=false', '--seed=false', '--sample=false', '--quiet', '--copy_storefront=false', '--install_storefront=false', "--user_class=#{args[:user_class]}"]
|
19
19
|
|
20
20
|
puts 'Setting up dummy database...'
|
21
21
|
system("bundle exec rake db:drop db:create > #{File::NULL}")
|
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
|
10
10
|
def spree_get(action, parameters = nil, session = nil, flash = nil)
|
11
11
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
12
|
-
ControllerRequests#spree_get is deprecated and will be removed in Spree
|
12
|
+
ControllerRequests#spree_get is deprecated and will be removed in Spree 5.0.
|
13
13
|
Please use get, params: {}
|
14
14
|
DEPRECATION
|
15
15
|
process_spree_action(action, parameters, session, flash, 'GET')
|
@@ -18,7 +18,7 @@ module Spree
|
|
18
18
|
# Executes a request simulating POST HTTP method and set/volley the response
|
19
19
|
def spree_post(action, parameters = nil, session = nil, flash = nil)
|
20
20
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
21
|
-
ControllerRequests#spree_post is deprecated and will be removed in Spree
|
21
|
+
ControllerRequests#spree_post is deprecated and will be removed in Spree 5.0.
|
22
22
|
Please use post, params: {}
|
23
23
|
DEPRECATION
|
24
24
|
process_spree_action(action, parameters, session, flash, 'POST')
|
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
# Executes a request simulating PUT HTTP method and set/volley the response
|
28
28
|
def spree_put(action, parameters = nil, session = nil, flash = nil)
|
29
29
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
30
|
-
ControllerRequests#spree_put is deprecated and will be removed in Spree
|
30
|
+
ControllerRequests#spree_put is deprecated and will be removed in Spree 5.0.
|
31
31
|
Please use put, params: {}
|
32
32
|
DEPRECATION
|
33
33
|
process_spree_action(action, parameters, session, flash, 'PUT')
|
@@ -36,7 +36,7 @@ module Spree
|
|
36
36
|
# # Executes a request simulating PATCH HTTP method and set/volley the response
|
37
37
|
def spree_patch(action, parameters = nil, session = nil, flash = nil)
|
38
38
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
39
|
-
ControllerRequests#spree_patch is deprecated and will be removed in Spree
|
39
|
+
ControllerRequests#spree_patch is deprecated and will be removed in Spree 5.0.
|
40
40
|
Please use patch, params: {}
|
41
41
|
DEPRECATION
|
42
42
|
process_spree_action(action, parameters, session, flash, 'PATCH')
|
@@ -45,7 +45,7 @@ module Spree
|
|
45
45
|
# Executes a request simulating DELETE HTTP method and set/volley the response
|
46
46
|
def spree_delete(action, parameters = nil, session = nil, flash = nil)
|
47
47
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
48
|
-
ControllerRequests#spree_delete is deprecated and will be removed in Spree
|
48
|
+
ControllerRequests#spree_delete is deprecated and will be removed in Spree 5.0.
|
49
49
|
Please use delete, params: {}
|
50
50
|
DEPRECATION
|
51
51
|
process_spree_action(action, parameters, session, flash, 'DELETE')
|
@@ -53,35 +53,35 @@ module Spree
|
|
53
53
|
|
54
54
|
def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
|
55
55
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
56
|
-
ControllerRequests#spree_xhr_get is deprecated and will be removed in Spree
|
56
|
+
ControllerRequests#spree_xhr_get is deprecated and will be removed in Spree 5.0.
|
57
57
|
DEPRECATION
|
58
58
|
process_spree_xhr_action(action, parameters, session, flash, :get)
|
59
59
|
end
|
60
60
|
|
61
61
|
def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
|
62
62
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
63
|
-
ControllerRequests#spree_xhr_post is deprecated and will be removed in Spree
|
63
|
+
ControllerRequests#spree_xhr_post is deprecated and will be removed in Spree 5.0.
|
64
64
|
DEPRECATION
|
65
65
|
process_spree_xhr_action(action, parameters, session, flash, :post)
|
66
66
|
end
|
67
67
|
|
68
68
|
def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
|
69
69
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
70
|
-
ControllerRequests#spree_xhr_put is deprecated and will be removed in Spree
|
70
|
+
ControllerRequests#spree_xhr_put is deprecated and will be removed in Spree 5.0.
|
71
71
|
DEPRECATION
|
72
72
|
process_spree_xhr_action(action, parameters, session, flash, :put)
|
73
73
|
end
|
74
74
|
|
75
75
|
def spree_xhr_patch(action, parameters = nil, session = nil, flash = nil)
|
76
76
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
77
|
-
ControllerRequests#spree_xhr_patch is deprecated and will be removed in Spree
|
77
|
+
ControllerRequests#spree_xhr_patch is deprecated and will be removed in Spree 5.0.
|
78
78
|
DEPRECATION
|
79
79
|
process_spree_xhr_action(action, parameters, session, flash, :patch)
|
80
80
|
end
|
81
81
|
|
82
82
|
def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
|
83
83
|
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
84
|
-
ControllerRequests#spree_xhr_delete is deprecated and will be removed in Spree
|
84
|
+
ControllerRequests#spree_xhr_delete is deprecated and will be removed in Spree 5.0.
|
85
85
|
DEPRECATION
|
86
86
|
process_spree_xhr_action(action, parameters, session, flash, :delete)
|
87
87
|
end
|
@@ -1,4 +1,21 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
+
trait :with_item_total_rule do
|
3
|
+
transient do
|
4
|
+
item_total_threshold_amount { 10 }
|
5
|
+
end
|
6
|
+
|
7
|
+
after(:create) do |promotion, evaluator|
|
8
|
+
rule = Spree::Promotion::Rules::ItemTotal.create!(
|
9
|
+
preferred_operator_min: 'gte',
|
10
|
+
preferred_operator_max: 'lte',
|
11
|
+
preferred_amount_min: evaluator.item_total_threshold_amount,
|
12
|
+
preferred_amount_max: evaluator.item_total_threshold_amount + 100
|
13
|
+
)
|
14
|
+
promotion.rules << rule
|
15
|
+
promotion.save!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
2
19
|
factory :promotion, class: Spree::Promotion do
|
3
20
|
name { 'Promo' }
|
4
21
|
|
@@ -13,7 +30,16 @@ FactoryBot.define do
|
|
13
30
|
Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion)
|
14
31
|
end
|
15
32
|
end
|
33
|
+
|
34
|
+
trait :with_one_use_per_user_rule do
|
35
|
+
after(:create) do |promotion|
|
36
|
+
rule = Spree::Promotion::Rules::OneUsePerUser.create!
|
37
|
+
promotion.rules << rule
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
16
41
|
factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
|
42
|
+
factory :promotion_with_one_use_per_user_rule, traits: [:with_line_item_adjustment, :with_one_use_per_user_rule]
|
17
43
|
|
18
44
|
trait :with_order_adjustment do
|
19
45
|
transient do
|
@@ -28,24 +54,8 @@ FactoryBot.define do
|
|
28
54
|
promotion.save!
|
29
55
|
end
|
30
56
|
end
|
31
|
-
factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
|
32
57
|
|
33
|
-
|
34
|
-
transient do
|
35
|
-
item_total_threshold_amount { 10 }
|
36
|
-
end
|
37
|
-
|
38
|
-
after(:create) do |promotion, evaluator|
|
39
|
-
rule = Spree::Promotion::Rules::ItemTotal.create!(
|
40
|
-
preferred_operator_min: 'gte',
|
41
|
-
preferred_operator_max: 'lte',
|
42
|
-
preferred_amount_min: evaluator.item_total_threshold_amount,
|
43
|
-
preferred_amount_max: evaluator.item_total_threshold_amount + 100
|
44
|
-
)
|
45
|
-
promotion.rules << rule
|
46
|
-
promotion.save!
|
47
|
-
end
|
48
|
-
end
|
58
|
+
factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
|
49
59
|
factory :promotion_with_item_total_rule, traits: [:with_item_total_rule]
|
50
60
|
end
|
51
61
|
|
@@ -57,5 +67,7 @@ FactoryBot.define do
|
|
57
67
|
action.promotion = promotion
|
58
68
|
action.save
|
59
69
|
end
|
70
|
+
|
71
|
+
factory :free_shipping_promotion_with_item_total_rule, traits: [:with_item_total_rule]
|
60
72
|
end
|
61
73
|
end
|
@@ -8,15 +8,13 @@ FactoryBot.define do
|
|
8
8
|
|
9
9
|
after(:create) do |shipment, _evalulator|
|
10
10
|
shipment.add_shipping_method(create(:shipping_method), true)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
19
|
-
end
|
11
|
+
shipment.order.line_items.map do |line_item|
|
12
|
+
shipment.inventory_units.create(
|
13
|
+
order_id: shipment.order_id,
|
14
|
+
variant_id: line_item.variant_id,
|
15
|
+
line_item_id: line_item.id,
|
16
|
+
quantity: line_item.quantity
|
17
|
+
)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -20,8 +20,8 @@ FactoryBot.define do
|
|
20
20
|
product_1 = create(:product)
|
21
21
|
product_2 = create(:product)
|
22
22
|
|
23
|
-
stock_location.stock_items.where(variant_id: product_1.
|
24
|
-
stock_location.stock_items.where(variant_id: product_2.
|
23
|
+
stock_location.stock_items.where(variant_id: product_1.master_id).first.adjust_count_on_hand(10)
|
24
|
+
stock_location.stock_items.where(variant_id: product_2.master_id).first.adjust_count_on_hand(20)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -8,6 +8,7 @@ FactoryBot.define do
|
|
8
8
|
new_order_notifications_email { 'store-owner@example.com' }
|
9
9
|
default_currency { 'USD' }
|
10
10
|
supported_currencies { 'USD,EUR,GBP' }
|
11
|
+
default_locale { 'en' }
|
11
12
|
facebook { 'spreecommerce' }
|
12
13
|
twitter { 'spreecommerce' }
|
13
14
|
instagram { 'spreecommerce' }
|
@@ -1,24 +1,27 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
-
factory :global_zone, class: Spree::Zone do
|
3
|
-
name { 'GlobalZone' }
|
4
|
-
description { generate(:random_string) }
|
5
|
-
zone_members do |proxy|
|
6
|
-
zone = proxy.instance_eval { @instance }
|
7
|
-
Spree::Country.all.map do |c|
|
8
|
-
Spree::ZoneMember.create(zoneable: c, zone: zone)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
2
|
factory :zone, class: Spree::Zone do
|
14
3
|
name { generate(:random_string) }
|
15
4
|
description { generate(:random_string) }
|
16
5
|
|
17
6
|
factory :zone_with_country do
|
7
|
+
kind { :country }
|
8
|
+
|
18
9
|
zone_members do |proxy|
|
19
10
|
zone = proxy.instance_eval { @instance }
|
20
|
-
|
21
|
-
[Spree::ZoneMember.create(zoneable: country, zone: zone)]
|
11
|
+
|
12
|
+
[Spree::ZoneMember.create(zoneable: create(:country), zone: zone)]
|
13
|
+
end
|
14
|
+
|
15
|
+
factory :global_zone, class: Spree::Zone do
|
16
|
+
sequence(:name) { |n| "GlobalZone_#{n}" }
|
17
|
+
|
18
|
+
zone_members do |proxy|
|
19
|
+
zone = proxy.instance_eval { @instance }
|
20
|
+
|
21
|
+
Spree::Country.all.map do |country|
|
22
|
+
Spree::ZoneMember.where(zoneable: country, zone: zone).first_or_create
|
23
|
+
end
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Spree
|
2
|
+
module TestingSupport
|
3
|
+
module FlatpickrCapybara
|
4
|
+
def fill_in_date_manually(label_text, with:)
|
5
|
+
with_open_flatpickr(label_text) do |field|
|
6
|
+
fill_in field[:id], with: with
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def fill_in_date_picker(label_text, with:)
|
11
|
+
within_open_flatpickr(label_text) do
|
12
|
+
within_flatpickr_months do
|
13
|
+
fill_in_flatpickr_year(with.split('-')[0])
|
14
|
+
|
15
|
+
select_flatpickr_month(with.split('-')[1])
|
16
|
+
|
17
|
+
click_on_flatpickr_day(with.split('-')[2])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def fill_in_date_time_picker(label_text, with:)
|
23
|
+
within_open_flatpickr(label_text) do
|
24
|
+
within_flatpickr_months do
|
25
|
+
fill_in_flatpickr_year(with.split('-')[0])
|
26
|
+
|
27
|
+
select_flatpickr_month(with.split('-')[1])
|
28
|
+
|
29
|
+
click_on_flatpickr_day(with.split('-')[2])
|
30
|
+
end
|
31
|
+
|
32
|
+
within_flatpickr_time do
|
33
|
+
select_flatpickr_hour(with.split('-')[3])
|
34
|
+
|
35
|
+
select_flatpickr_min(with.split('-')[4])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def fill_in_date_with_js(label_text, with:)
|
41
|
+
date_field = find("input[id='#{label_text}']")
|
42
|
+
script = "document.querySelector('#{date_field}').flatpickr().setDate('#{with}');"
|
43
|
+
|
44
|
+
page.execute_script(script)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def with_open_flatpickr(label_text)
|
50
|
+
field_label = find_field(id: label_text, type: :hidden)
|
51
|
+
|
52
|
+
date_field = field_label.sibling('.flatpickr-alt-input')
|
53
|
+
date_field.click # Open the widget
|
54
|
+
|
55
|
+
yield(date_field)
|
56
|
+
|
57
|
+
date_field.send_keys :tab # Close the date picker widget
|
58
|
+
end
|
59
|
+
|
60
|
+
def within_open_flatpickr(label_text)
|
61
|
+
with_open_flatpickr(label_text) do
|
62
|
+
within find(:xpath, "/html/body/div[contains(@class, 'flatpickr-calendar')]") { yield }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def within_flatpickr_months
|
67
|
+
within find('.flatpickr-months .flatpickr-month .flatpickr-current-month') { yield }
|
68
|
+
end
|
69
|
+
|
70
|
+
def within_flatpickr_time
|
71
|
+
within find('.flatpickr-time') { yield }
|
72
|
+
end
|
73
|
+
|
74
|
+
def select_flatpickr_month(month)
|
75
|
+
find("select.flatpickr-monthDropdown-months > option:nth-child(#{month.to_i})").select_option
|
76
|
+
end
|
77
|
+
|
78
|
+
def fill_in_flatpickr_year(year)
|
79
|
+
find('input.cur-year').set(year)
|
80
|
+
end
|
81
|
+
|
82
|
+
def click_on_flatpickr_day(day)
|
83
|
+
within_flatpickr_days do
|
84
|
+
find('span', text: day).click
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def within_flatpickr_days
|
89
|
+
within find('.flatpickr-innerContainer > .flatpickr-rContainer > .flatpickr-days') { yield }
|
90
|
+
end
|
91
|
+
|
92
|
+
def select_flatpickr_hour(hour)
|
93
|
+
find('input.flatpickr-hour').set(hour)
|
94
|
+
end
|
95
|
+
|
96
|
+
def select_flatpickr_min(min)
|
97
|
+
find('input.flatpickr-minute').set(min)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|