spree_core 5.3.1 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/spree/export.rb +5 -1
- data/app/models/spree/import.rb +4 -0
- data/app/models/spree/invitation.rb +1 -1
- data/app/models/spree/order/address_book.rb +12 -4
- data/app/models/spree/order/store_credit.rb +4 -1
- data/app/models/spree/payment.rb +4 -4
- data/app/models/spree/report.rb +4 -0
- data/app/models/spree/store_product.rb +2 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -6
- data/lib/spree/core/controller_helpers/auth.rb +2 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/common_rake.rb +54 -1
- data/lib/spree/testing_support/extension_rake.rb +15 -2
- data/lib/spree/testing_support/factories/calculator_factory.rb +4 -4
- data/lib/spree/testing_support/factories/custom_domain_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_group_user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/export_factory.rb +2 -2
- data/lib/spree/testing_support/factories/google_data_feed_factory.rb +1 -2
- data/lib/spree/testing_support/factories/import_factory.rb +1 -1
- data/lib/spree/testing_support/factories/invitation_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +11 -6
- data/lib/spree/testing_support/factories/order_factory.rb +5 -5
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/post_factory.rb +3 -3
- data/lib/spree/testing_support/factories/product_factory.rb +6 -3
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/prototype_factory.rb +3 -3
- data/lib/spree/testing_support/factories/report_factory.rb +4 -4
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +3 -3
- data/lib/spree/testing_support/factories/user_factory.rb +3 -5
- data/lib/spree/testing_support/factories/variant_factory.rb +3 -4
- data/lib/spree/testing_support/factories/zone_factory.rb +8 -5
- data/lib/spree/testing_support/factories.rb +1 -1
- data/lib/spree/testing_support/store.rb +1 -5
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08d9b1a3cf8bea4f049c9dd444d3f1977e5752adfec8d31dc1fd91d8ee7ccc00'
|
|
4
|
+
data.tar.gz: c3653bae9f794377013d94700bee1eaa9da04485737584af25f103f091e662f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 987979ba7a79782bd0412b510a3ecf566b61adfc6af241801a547c5b26bd401e3a16475cfdd3712ab29db5c062a5e8dfadea2d7c21634e773b0dd8fbab8f0423
|
|
7
|
+
data.tar.gz: 73229e1625bafe9ca1c1d8d00d0d1069bdca226aa91ee462abad53e618e4cd546a09cc242d9829a3f7a74ddae11e0ab69f9e4f9bdaf245ae1b4748af95ecb46a
|
data/app/models/spree/export.rb
CHANGED
|
@@ -57,6 +57,10 @@ module Spree
|
|
|
57
57
|
#
|
|
58
58
|
attribute :record_selection, :string, default: 'filtered'
|
|
59
59
|
|
|
60
|
+
def event_serializer_class
|
|
61
|
+
Spree::Events::ExportSerializer
|
|
62
|
+
end
|
|
63
|
+
|
|
60
64
|
def done?
|
|
61
65
|
attachment.present? && attachment.attached?
|
|
62
66
|
end
|
|
@@ -196,7 +200,7 @@ module Spree
|
|
|
196
200
|
def model_class
|
|
197
201
|
klass = "Spree::#{to_s.demodulize.singularize}".safe_constantize
|
|
198
202
|
|
|
199
|
-
raise NameError, "Missing model class for #{
|
|
203
|
+
raise NameError, "Missing model class for #{self}" unless klass
|
|
200
204
|
|
|
201
205
|
klass
|
|
202
206
|
end
|
data/app/models/spree/import.rb
CHANGED
|
@@ -225,6 +225,10 @@ module Spree
|
|
|
225
225
|
@current_ability ||= Spree.ability_class.new(user, { store: store })
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
def event_serializer_class
|
|
229
|
+
Spree::Events::ImportSerializer
|
|
230
|
+
end
|
|
231
|
+
|
|
228
232
|
class << self
|
|
229
233
|
# Returns the available types for the import
|
|
230
234
|
# @return [Array<Class>]
|
|
@@ -54,7 +54,7 @@ module Spree
|
|
|
54
54
|
#
|
|
55
55
|
after_initialize :set_defaults, if: :new_record?
|
|
56
56
|
before_validation :set_invitee_from_email, on: :create
|
|
57
|
-
|
|
57
|
+
after_commit :publish_invitation_created_event, on: :create, unless: :skip_email
|
|
58
58
|
|
|
59
59
|
# returns the store for the invitation
|
|
60
60
|
# if the resource is a store, return the resource
|
|
@@ -14,13 +14,17 @@ module Spree
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def bill_address_id=(id)
|
|
17
|
+
return if bill_address_id == id
|
|
18
|
+
|
|
17
19
|
address = Spree::Address.find_by(id: id)
|
|
18
|
-
|
|
20
|
+
# rubocop:disable Style/ConditionalAssignment
|
|
21
|
+
if address && user_id.present? && address.user_id == user_id
|
|
19
22
|
self['bill_address_id'] = address.id
|
|
20
|
-
bill_address.reload
|
|
21
23
|
else
|
|
22
24
|
self['bill_address_id'] = nil
|
|
23
25
|
end
|
|
26
|
+
# rubocop:enable Style/ConditionalAssignment
|
|
27
|
+
reset_bill_address
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def bill_address_attributes=(attributes)
|
|
@@ -29,13 +33,17 @@ module Spree
|
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def ship_address_id=(id)
|
|
36
|
+
return if ship_address_id == id
|
|
37
|
+
|
|
32
38
|
address = Spree::Address.find_by(id: id)
|
|
33
|
-
|
|
39
|
+
# rubocop:disable Style/ConditionalAssignment
|
|
40
|
+
if address && user_id.present? && address.user_id == user_id
|
|
34
41
|
self['ship_address_id'] = address.id
|
|
35
|
-
ship_address.reload
|
|
36
42
|
else
|
|
37
43
|
self['ship_address_id'] = nil
|
|
38
44
|
end
|
|
45
|
+
# rubocop:enable Style/ConditionalAssignment
|
|
46
|
+
reset_ship_address
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
def ship_address_attributes=(attributes)
|
|
@@ -66,7 +66,10 @@ module Spree
|
|
|
66
66
|
# @return [BigDecimal] The total amount of store credits applied to the order.
|
|
67
67
|
def total_applied_store_credit
|
|
68
68
|
if payments.loaded?
|
|
69
|
-
payments.
|
|
69
|
+
payments.
|
|
70
|
+
find_all(&:store_credit?).
|
|
71
|
+
reject(&:has_invalid_state?).
|
|
72
|
+
sum(&:amount) || BigDecimal::ZERO
|
|
70
73
|
else
|
|
71
74
|
payments.store_credits.valid.sum(:amount)
|
|
72
75
|
end
|
data/app/models/spree/payment.rb
CHANGED
|
@@ -278,6 +278,10 @@ module Spree
|
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
|
|
281
|
+
def has_invalid_state?
|
|
282
|
+
INVALID_STATES.include?(state)
|
|
283
|
+
end
|
|
284
|
+
|
|
281
285
|
private
|
|
282
286
|
|
|
283
287
|
def set_amount
|
|
@@ -302,10 +306,6 @@ module Spree
|
|
|
302
306
|
publish_event('payment.voided')
|
|
303
307
|
end
|
|
304
308
|
|
|
305
|
-
def has_invalid_state?
|
|
306
|
-
INVALID_STATES.include?(state)
|
|
307
|
-
end
|
|
308
|
-
|
|
309
309
|
def validate_source
|
|
310
310
|
if source && !source.valid?
|
|
311
311
|
source.errors.map { |error| { field: error.attribute, message: error&.message } }.each do |err|
|
data/app/models/spree/report.rb
CHANGED
|
@@ -9,6 +9,8 @@ module Spree
|
|
|
9
9
|
validates :store_id, uniqueness: { scope: :product_id }
|
|
10
10
|
|
|
11
11
|
def refresh_metrics!
|
|
12
|
+
return if product.nil?
|
|
13
|
+
|
|
12
14
|
completed_order_ids = product.completed_orders.where(store_id: store_id).select(:id)
|
|
13
15
|
variant_ids = product.variants_including_master.ids
|
|
14
16
|
|
|
@@ -14,7 +14,7 @@ development:
|
|
|
14
14
|
database: db/spree_development.sqlite3
|
|
15
15
|
test:
|
|
16
16
|
adapter: sqlite3
|
|
17
|
-
database: db/spree_test
|
|
17
|
+
database: db/spree_test<%%= ENV['TEST_ENV_NUMBER'] %>.sqlite3
|
|
18
18
|
timeout: 10000
|
|
19
19
|
production:
|
|
20
20
|
adapter: sqlite3
|
|
@@ -40,7 +40,7 @@ development:
|
|
|
40
40
|
database: <%= database_prefix %><%= lib_name %>_spree_development
|
|
41
41
|
test:
|
|
42
42
|
<<: *mysql
|
|
43
|
-
database: <%= database_prefix %><%= lib_name %>_spree_test
|
|
43
|
+
database: <%= database_prefix %><%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
|
|
44
44
|
production:
|
|
45
45
|
<<: *mysql
|
|
46
46
|
database: <%= database_prefix %><%= lib_name %>_spree_production
|
|
@@ -57,14 +57,14 @@ postgres: &postgres
|
|
|
57
57
|
host: <%= db_host %>
|
|
58
58
|
<% end %>
|
|
59
59
|
min_messages: warning
|
|
60
|
-
pool:
|
|
60
|
+
pool: <%%= ENV.fetch("DB_POOL", 50) %>
|
|
61
61
|
|
|
62
62
|
development:
|
|
63
63
|
<<: *postgres
|
|
64
64
|
database: <%= database_prefix %><%= lib_name %>_spree_development
|
|
65
65
|
test:
|
|
66
66
|
<<: *postgres
|
|
67
|
-
database: <%= database_prefix %><%= lib_name %>_spree_test
|
|
67
|
+
database: <%= database_prefix %><%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
|
|
68
68
|
production:
|
|
69
69
|
<<: *postgres
|
|
70
70
|
database: <%= database_prefix %><%= lib_name %>_spree_production
|
|
@@ -74,8 +74,8 @@ development:
|
|
|
74
74
|
database: db/spree_development.sqlite3
|
|
75
75
|
test:
|
|
76
76
|
adapter: sqlite3
|
|
77
|
-
database: db/spree_test
|
|
77
|
+
database: db/spree_test<%%= ENV['TEST_ENV_NUMBER'] %>.sqlite3
|
|
78
78
|
production:
|
|
79
79
|
adapter: sqlite3
|
|
80
80
|
database: db/spree_production.sqlite3
|
|
81
|
-
<% end %>
|
|
81
|
+
<% end %>
|
|
@@ -21,6 +21,8 @@ module Spree
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def current_oauth_token
|
|
24
|
+
Spree::Deprecation.warn('Spree::Current.oauth_token is deprecated and will be removed in Spree 5.5')
|
|
25
|
+
|
|
24
26
|
get_last_access_token = ->(user) { Spree::OauthAccessToken.active_for(user).where(expires_in: nil).last }
|
|
25
27
|
create_access_token = ->(user) { Spree::OauthAccessToken.create!(resource_owner: user) }
|
|
26
28
|
user = try_spree_current_user
|
data/lib/spree/core/version.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'generators/spree/dummy_model/dummy_model_generator'
|
|
|
3
3
|
|
|
4
4
|
desc 'Generates a dummy app for testing'
|
|
5
5
|
namespace :common do
|
|
6
|
-
task :test_app, :user_class do |_t, args|
|
|
6
|
+
task :test_app, [:authentication, :user_class, :admin_user_class, :css, :javascript, :install_admin, :install_storefront] do |_t, args|
|
|
7
7
|
args.with_defaults(
|
|
8
8
|
authentication: 'dummy',
|
|
9
9
|
user_class: 'Spree::LegacyUser',
|
|
@@ -134,3 +134,56 @@ namespace :common do
|
|
|
134
134
|
system('bundle exec rake db:seed RAILS_ENV=test > /dev/null 2>&1')
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
|
+
|
|
138
|
+
# Custom parallel setup task instead of parallel_tests' native parallel:create/parallel:prepare
|
|
139
|
+
# because Spree gems are not Rails apps — the Rails app lives in spec/dummy/ and db: rake tasks
|
|
140
|
+
# are not available from the gem directory. For SQLite, we copy the primary .sqlite3 file which
|
|
141
|
+
# is faster than creating + migrating N databases through Rails.
|
|
142
|
+
desc 'Create and prepare databases for parallel test workers'
|
|
143
|
+
task :parallel_setup, [:count] do |_t, args|
|
|
144
|
+
require 'parallel'
|
|
145
|
+
|
|
146
|
+
count = (args[:count] || ENV.fetch('PARALLEL_TEST_PROCESSORS', Parallel.processor_count)).to_i
|
|
147
|
+
dummy_path = ENV['DUMMY_PATH'] || 'spec/dummy'
|
|
148
|
+
db_config_path = File.join(dummy_path, 'config', 'database.yml')
|
|
149
|
+
|
|
150
|
+
raise "Database config not found at #{db_config_path}. Run 'rake test_app' first." unless File.exist?(db_config_path)
|
|
151
|
+
|
|
152
|
+
require 'erb'
|
|
153
|
+
require 'yaml'
|
|
154
|
+
|
|
155
|
+
db_config = YAML.safe_load(ERB.new(File.read(db_config_path)).result, permitted_classes: [Symbol])
|
|
156
|
+
adapter = db_config.dig('test', 'adapter')
|
|
157
|
+
|
|
158
|
+
if adapter == 'sqlite3'
|
|
159
|
+
# For SQLite, copy the primary test database for each worker
|
|
160
|
+
primary_db = File.join(dummy_path, db_config.dig('test', 'database'))
|
|
161
|
+
|
|
162
|
+
raise "Primary test database not found at #{primary_db}. Run 'rake test_app' first." unless File.exist?(primary_db)
|
|
163
|
+
|
|
164
|
+
2.upto(count) do |i|
|
|
165
|
+
worker_db = primary_db.sub(/\.sqlite3$/, "#{i}.sqlite3")
|
|
166
|
+
FileUtils.cp(primary_db, worker_db)
|
|
167
|
+
puts "Created parallel database: #{worker_db}"
|
|
168
|
+
end
|
|
169
|
+
else
|
|
170
|
+
# For PostgreSQL/MySQL, create and migrate each worker's database
|
|
171
|
+
2.upto(count) do |i|
|
|
172
|
+
env_vars = "TEST_ENV_NUMBER=#{i} RAILS_ENV=test"
|
|
173
|
+
puts "Setting up database for worker #{i}..."
|
|
174
|
+
Dir.chdir(dummy_path) do
|
|
175
|
+
system("#{env_vars} bundle exec rake db:create db:migrate") || raise("Failed to setup database for worker #{i}")
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
puts "Parallel databases setup complete (#{count} workers)"
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
desc 'Run specs in parallel'
|
|
184
|
+
task :parallel_spec, [:count] do |_t, args|
|
|
185
|
+
count = args[:count] || ENV.fetch('PARALLEL_TEST_PROCESSORS', nil)
|
|
186
|
+
count_arg = count ? "-n #{count}" : ''
|
|
187
|
+
success = system("bundle exec parallel_rspec #{count_arg} spec")
|
|
188
|
+
exit(success ? 0 : 1)
|
|
189
|
+
end
|
|
@@ -2,8 +2,21 @@ require 'spree/testing_support/common_rake'
|
|
|
2
2
|
|
|
3
3
|
desc 'Generates a dummy app for testing an extension'
|
|
4
4
|
namespace :extension do
|
|
5
|
-
task :test_app, [:
|
|
5
|
+
task :test_app, [:options] do |_t, args|
|
|
6
6
|
Spree::DummyGeneratorHelper.inject_extension_requirements = true
|
|
7
|
-
|
|
7
|
+
# Support both hash passed as first arg and named options
|
|
8
|
+
options = args[:options].is_a?(Hash) ? args[:options] : args.to_h
|
|
9
|
+
Rake::Task['common:test_app'].execute(Rake::TaskArguments.new(
|
|
10
|
+
[:authentication, :user_class, :admin_user_class, :css, :javascript, :install_admin, :install_storefront],
|
|
11
|
+
[
|
|
12
|
+
options[:authentication],
|
|
13
|
+
options[:user_class],
|
|
14
|
+
options[:admin_user_class],
|
|
15
|
+
options[:css],
|
|
16
|
+
options[:javascript],
|
|
17
|
+
options[:install_admin],
|
|
18
|
+
options[:install_storefront]
|
|
19
|
+
]
|
|
20
|
+
))
|
|
8
21
|
end
|
|
9
22
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :calculator, class: Spree::Calculator::FlatRate do
|
|
3
|
-
|
|
3
|
+
preferred_amount { 10.0 }
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
factory :no_amount_calculator, class: Spree::Calculator::FlatRate do
|
|
7
|
-
|
|
7
|
+
preferred_amount { 0 }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
factory :default_tax_calculator, class: Spree::Calculator::DefaultTax do
|
|
@@ -27,10 +27,10 @@ FactoryBot.define do
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
factory :non_free_shipping_calculator, class: Spree::Calculator::Shipping::FlatRate do
|
|
30
|
-
|
|
30
|
+
preferred_amount { 20.0 }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
factory :digital_shipping_calculator, class: Spree::Calculator::Shipping::DigitalDelivery do
|
|
34
|
-
|
|
34
|
+
preferred_amount { 0 }
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :import, class: 'Spree::Import' do
|
|
3
3
|
owner { Spree::Store.default || create(:store) }
|
|
4
|
-
user
|
|
4
|
+
association :user, factory: :admin_user
|
|
5
5
|
type { 'Spree::Imports::Products' }
|
|
6
6
|
|
|
7
7
|
factory :product_import, class: 'Spree::Imports::Products', parent: :import do
|
|
@@ -4,13 +4,18 @@ FactoryBot.define do
|
|
|
4
4
|
quantity { 1 }
|
|
5
5
|
price { BigDecimal('10.00') }
|
|
6
6
|
currency { order.currency }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
transient do
|
|
8
|
+
product { nil }
|
|
9
|
+
end
|
|
10
|
+
variant do
|
|
11
|
+
resolved_product = product || begin
|
|
12
|
+
if order&.store&.present?
|
|
13
|
+
create(:product, stores: [order.store])
|
|
14
|
+
else
|
|
15
|
+
create(:product)
|
|
16
|
+
end
|
|
12
17
|
end
|
|
18
|
+
resolved_product.master
|
|
13
19
|
end
|
|
14
|
-
variant { product.master }
|
|
15
20
|
end
|
|
16
21
|
end
|
|
@@ -13,10 +13,11 @@ FactoryBot.define do
|
|
|
13
13
|
|
|
14
14
|
before(:create) do |order|
|
|
15
15
|
unless order.store.present?
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
store = begin
|
|
17
|
+
default = Spree::Store.default
|
|
18
|
+
default&.persisted? ? default : nil
|
|
19
|
+
end
|
|
20
|
+
order.store = store || create(:store)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
|
|
@@ -42,7 +43,6 @@ FactoryBot.define do
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
factory :order_with_line_items do
|
|
45
|
-
bill_address
|
|
46
46
|
ship_address
|
|
47
47
|
|
|
48
48
|
transient do
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :post, class: Spree::Post do
|
|
3
|
-
|
|
3
|
+
store { Spree::Store.default || create(:store) }
|
|
4
|
+
post_category { association(:post_category, store: store) }
|
|
4
5
|
title { FFaker::Lorem.sentence }
|
|
5
6
|
content { FFaker::Lorem.paragraph }
|
|
6
7
|
published_at { Time.current }
|
|
7
|
-
author
|
|
8
|
-
store { Spree::Store.default || create(:store) }
|
|
8
|
+
association :author, factory: :admin_user
|
|
9
9
|
|
|
10
10
|
trait :with_image do
|
|
11
11
|
image { Rack::Test::UploadedFile.new(Spree::Core::Engine.root.join('spec/fixtures/thinking-cat.jpg'), 'image/jpeg') }
|
|
@@ -19,7 +19,10 @@ FactoryBot.define do
|
|
|
19
19
|
create(:store, default: true) unless Spree::Store.any?
|
|
20
20
|
end
|
|
21
21
|
after(:create) do |product|
|
|
22
|
-
|
|
22
|
+
existing_location_ids = product.master.stock_items.pluck(:stock_location_id)
|
|
23
|
+
Spree::StockLocation.where.not(id: existing_location_ids).find_each do |stock_location|
|
|
24
|
+
stock_location.propagate_variant(product.master)
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
factory :custom_product do
|
|
@@ -49,8 +52,8 @@ FactoryBot.define do
|
|
|
49
52
|
end
|
|
50
53
|
factory :product_with_properties do
|
|
51
54
|
after(:create) do |product|
|
|
52
|
-
create(:property, :brand
|
|
53
|
-
create(:product_property, product: product,
|
|
55
|
+
property = create(:property, :brand)
|
|
56
|
+
create(:product_property, product: product, property: property, value: 'Epsilon')
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :prototype, class: Spree::Prototype do
|
|
3
3
|
name { 'Baseball Cap' }
|
|
4
|
-
properties { [
|
|
4
|
+
properties { [build(:property)] }
|
|
5
5
|
end
|
|
6
6
|
factory :prototype_with_option_types, class: Spree::Prototype do
|
|
7
7
|
name { 'Baseball Cap' }
|
|
8
|
-
properties { [
|
|
9
|
-
option_types { [
|
|
8
|
+
properties { [build(:property)] }
|
|
9
|
+
option_types { [build(:option_type)] }
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
#
|
|
15
15
|
FactoryBot.define do
|
|
16
16
|
factory :report, class: 'Spree::Reports::SalesTotal' do
|
|
17
|
-
store
|
|
18
|
-
user
|
|
17
|
+
association :store, factory: :store
|
|
18
|
+
association :user, factory: :admin_user
|
|
19
19
|
type { 'Spree::Reports::SalesTotal' }
|
|
20
20
|
currency { 'USD' }
|
|
21
21
|
date_from { 1.month.ago }
|
|
@@ -23,8 +23,8 @@ FactoryBot.define do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
factory :products_performance_report, class: 'Spree::Reports::ProductsPerformance' do
|
|
26
|
-
store
|
|
27
|
-
user
|
|
26
|
+
association :store, factory: :store
|
|
27
|
+
association :user, factory: :admin_user
|
|
28
28
|
type { 'Spree::Reports::ProductsPerformance' }
|
|
29
29
|
currency { 'USD' }
|
|
30
30
|
date_from { 1.month.ago }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :store_credit_auth_event, class: Spree::StoreCreditEvent do
|
|
3
|
-
store_credit
|
|
3
|
+
association :store_credit, factory: :store_credit
|
|
4
4
|
action { Spree::StoreCredit::AUTHORIZE_ACTION }
|
|
5
5
|
amount { 100.00 }
|
|
6
6
|
authorization_code { "#{store_credit.id}-SC-20140602164814476128" }
|
|
@@ -3,11 +3,11 @@ FactoryBot.define do
|
|
|
3
3
|
|
|
4
4
|
factory :store_credit, class: Spree::StoreCredit do
|
|
5
5
|
user
|
|
6
|
-
created_by
|
|
7
|
-
category
|
|
6
|
+
association :created_by, factory: :admin_user
|
|
7
|
+
association :category, factory: :store_credit_category
|
|
8
8
|
amount { 150.00 }
|
|
9
9
|
currency { 'USD' }
|
|
10
|
-
credit_type
|
|
10
|
+
association :credit_type, factory: :primary_credit_type
|
|
11
11
|
store { Spree::Store.default || create(:store) }
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -13,11 +13,9 @@ FactoryBot.define do
|
|
|
13
13
|
|
|
14
14
|
factory :user_with_addresses, aliases: [:user_with_addreses] do
|
|
15
15
|
after(:create) do |user|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
user.
|
|
19
|
-
user.addresses << user.bill_address
|
|
20
|
-
user.save
|
|
16
|
+
ship_address = create(:address, user: user)
|
|
17
|
+
bill_address = create(:address, user: user)
|
|
18
|
+
user.update_columns(ship_address_id: ship_address.id, bill_address_id: bill_address.id)
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
end
|
|
@@ -13,7 +13,7 @@ FactoryBot.define do
|
|
|
13
13
|
track_inventory { true }
|
|
14
14
|
|
|
15
15
|
product { |p| p.association(:base_product, stores: [Spree::Store.default]) }
|
|
16
|
-
option_values { [
|
|
16
|
+
option_values { [build(:option_value)] }
|
|
17
17
|
|
|
18
18
|
transient do
|
|
19
19
|
create_stock { true }
|
|
@@ -26,9 +26,8 @@ FactoryBot.define do
|
|
|
26
26
|
|
|
27
27
|
after(:create) do |variant, evaluator|
|
|
28
28
|
if evaluator.create_stock
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
existing_location_ids = variant.stock_items.pluck(:stock_location_id)
|
|
30
|
+
Spree::StockLocation.where.not(id: existing_location_ids).find_each do |stock_location|
|
|
32
31
|
stock_location.propagate_variant(variant)
|
|
33
32
|
end
|
|
34
33
|
end
|
|
@@ -13,13 +13,16 @@ FactoryBot.define do
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
factory :global_zone, class: Spree::Zone do
|
|
16
|
-
|
|
16
|
+
name { 'GlobalZone' }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
after(:create) do |zone|
|
|
19
|
+
country_ids = Spree::Country.pluck(:id)
|
|
20
|
+
existing_ids = zone.zone_members.where(zoneable_type: 'Spree::Country').pluck(:zoneable_id)
|
|
21
|
+
new_ids = country_ids - existing_ids
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
Spree::
|
|
23
|
+
if new_ids.any?
|
|
24
|
+
records = new_ids.map { |id| { zoneable_type: 'Spree::Country', zoneable_id: id, zone_id: zone.id, created_at: Time.current, updated_at: Time.current } }
|
|
25
|
+
Spree::ZoneMember.insert_all(records)
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
end
|
|
@@ -34,10 +34,6 @@ RSpec.configure do |config|
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
config.after(:all) do
|
|
37
|
-
|
|
38
|
-
DatabaseCleaner.strategy = :transaction
|
|
39
|
-
DatabaseCleaner.clean_with(:truncation)
|
|
40
|
-
clear_enqueued_jobs
|
|
41
|
-
end
|
|
37
|
+
clear_enqueued_jobs
|
|
42
38
|
end
|
|
43
39
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.3.
|
|
4
|
+
version: 5.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
@@ -1717,9 +1717,9 @@ licenses:
|
|
|
1717
1717
|
- BSD-3-Clause
|
|
1718
1718
|
metadata:
|
|
1719
1719
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
1720
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.
|
|
1720
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.3
|
|
1721
1721
|
documentation_uri: https://docs.spreecommerce.org/
|
|
1722
|
-
source_code_uri: https://github.com/spree/spree/tree/v5.3.
|
|
1722
|
+
source_code_uri: https://github.com/spree/spree/tree/v5.3.3
|
|
1723
1723
|
rdoc_options: []
|
|
1724
1724
|
require_paths:
|
|
1725
1725
|
- lib
|