spree_core 5.0.6 → 5.1.0.beta
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/assets/images/logo.png +0 -0
- data/app/finders/spree/products/find.rb +28 -1
- data/app/finders/spree/taxons/find.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -6
- data/app/helpers/spree/images_helper.rb +12 -13
- data/app/helpers/spree/integrations_helper.rb +15 -0
- data/app/helpers/spree/mail_helper.rb +3 -4
- data/app/javascript/spree/core/controllers/disable_submit_button_controller.js +19 -0
- data/app/mailers/spree/invitation_mailer.rb +24 -0
- data/app/models/concerns/spree/integrations_concern.rb +11 -0
- data/app/models/concerns/spree/product_scopes.rb +6 -6
- data/app/models/concerns/spree/translatable_resource.rb +4 -0
- data/app/models/concerns/spree/translatable_resource_scopes.rb +17 -3
- data/app/models/concerns/spree/unique_name.rb +2 -0
- data/app/models/concerns/spree/user_management.rb +33 -0
- data/app/models/concerns/spree/user_methods.rb +19 -0
- data/app/models/concerns/spree/user_roles.rb +43 -17
- data/app/models/spree/ability.rb +8 -6
- data/app/models/spree/asset.rb +1 -6
- data/app/models/spree/base.rb +1 -0
- data/app/models/spree/base_analytics_event_handler.rb +7 -2
- data/app/models/spree/classification.rb +13 -0
- data/app/models/spree/credit_card.rb +24 -2
- data/app/models/spree/custom_domain.rb +3 -2
- data/app/models/spree/export.rb +1 -1
- data/app/models/spree/integration.rb +63 -0
- data/app/models/spree/invitation.rb +153 -0
- data/app/models/spree/invitations/store.rb +6 -0
- data/app/models/spree/option_value.rb +2 -2
- data/app/models/spree/order.rb +16 -5
- data/app/models/spree/order_merger.rb +7 -5
- data/app/models/spree/page_sections/featured_posts.rb +0 -4
- data/app/models/spree/payment.rb +1 -2
- data/app/models/spree/payment_source.rb +0 -21
- data/app/models/spree/post.rb +0 -1
- data/app/models/spree/product.rb +75 -5
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/rules/item_total.rb +12 -12
- data/app/models/spree/property.rb +3 -1
- data/app/models/spree/reports/sales_total.rb +5 -1
- data/app/models/spree/role.rb +16 -0
- data/app/models/spree/role_user.rb +32 -1
- data/app/models/spree/shipment_handler.rb +1 -0
- data/app/models/spree/shipping_method.rb +2 -2
- data/app/models/spree/store.rb +9 -4
- data/app/models/spree/store_credit_category.rb +4 -0
- data/app/models/spree/taxon.rb +4 -7
- data/app/models/spree/theme.rb +1 -1
- data/app/models/spree/wishlist.rb +0 -7
- data/app/services/spree/country_to_timezone.rb +273 -0
- data/app/services/spree/products/prepare_nested_attributes.rb +2 -9
- data/app/services/spree/seeds/admin_user.rb +4 -2
- data/app/services/spree/seeds/all.rb +3 -1
- data/app/services/spree/seeds/digital_delivery.rb +20 -0
- data/app/services/spree/seeds/returns_environment.rb +27 -0
- data/app/services/spree/seeds/tax_categories.rb +12 -0
- data/app/services/spree/stores/settings_defaults_by_country.rb +38 -0
- data/app/services/spree/tags/bulk_add.rb +13 -7
- data/app/views/spree/addresses/_form.html.erb +1 -1
- data/app/views/spree/invitation_mailer/invitation_accepted.html.erb +12 -0
- data/app/views/spree/invitation_mailer/invitation_email.html.erb +21 -0
- data/app/views/spree/shared/_payment.html.erb +0 -9
- data/config/locales/en.yml +48 -20
- data/db/migrate/20250407085228_create_spree_integrations.rb +12 -0
- data/db/migrate/20250410061306_create_spree_invitations.rb +20 -0
- data/db/migrate/20250418174652_add_resource_to_spree_role_users.rb +8 -0
- data/db/migrate/20250508060800_add_selected_locale_to_spree_admin_users.rb +8 -0
- data/db/migrate/20250509143831_add_session_id_to_spree_assets.rb +5 -0
- data/lib/generators/spree/authentication/devise/templates/authentication_helpers.rb.tt +3 -3
- data/lib/spree/core/controller_helpers/auth.rb +15 -14
- data/lib/spree/core/controller_helpers/currency.rb +11 -0
- data/lib/spree/core/controller_helpers/strong_parameters.rb +3 -2
- data/lib/spree/core/engine.rb +13 -3
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +1 -0
- data/lib/spree/permitted_attributes.rb +111 -13
- data/lib/spree/testing_support/common_rake.rb +7 -25
- data/lib/spree/testing_support/extension_rake.rb +1 -1
- data/lib/spree/testing_support/factories/integration_factory.rb +7 -0
- data/lib/spree/testing_support/factories/invitation_factory.rb +6 -0
- data/lib/spree/testing_support/factories/page_section_factory.rb +0 -4
- data/lib/spree/testing_support/factories/payment_factory.rb +0 -5
- data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -5
- data/lib/spree/testing_support/factories/promotion_action_factory.rb +4 -0
- data/lib/spree/testing_support/factories/taxon_factory.rb +0 -6
- data/lib/spree/testing_support/factories/user_factory.rb +14 -1
- data/lib/spree/translation_migrations.rb +27 -15
- data/lib/tasks/core.rake +8 -0
- metadata +41 -8
- data/app/models/concerns/spree/payment_source_concern.rb +0 -39
- data/app/models/spree/gateway/custom_payment_source_method.rb +0 -33
- data/app/models/spree/product/slugs.rb +0 -112
- data/lib/spree/testing_support/factories/payment_source_factory.rb +0 -5
@@ -2,38 +2,65 @@ module Spree
|
|
2
2
|
module PermittedAttributes
|
3
3
|
ATTRIBUTES = [
|
4
4
|
:address_attributes,
|
5
|
+
:asset_attributes,
|
5
6
|
:checkout_attributes,
|
6
7
|
:classification_attributes,
|
7
8
|
:cms_page_attributes,
|
8
9
|
:cms_section_attributes,
|
10
|
+
:custom_domain_attributes,
|
9
11
|
:customer_return_attributes,
|
10
12
|
:digital_attributes,
|
11
13
|
:digital_link_attributes,
|
14
|
+
:export_attributes,
|
12
15
|
:image_attributes,
|
16
|
+
:integration_attributes,
|
13
17
|
:inventory_unit_attributes,
|
18
|
+
:invitation_attributes,
|
14
19
|
:line_item_attributes,
|
15
20
|
:menu_attributes,
|
16
21
|
:menu_item_attributes,
|
17
22
|
:option_type_attributes,
|
18
23
|
:option_value_attributes,
|
24
|
+
:page_attributes,
|
25
|
+
:page_link_attributes,
|
26
|
+
:page_section_attributes,
|
19
27
|
:payment_attributes,
|
28
|
+
:payment_method_attributes,
|
20
29
|
:product_attributes,
|
30
|
+
:promotion_attributes,
|
31
|
+
:promotion_rule_attributes,
|
32
|
+
:promotion_action_attributes,
|
21
33
|
:product_properties_attributes,
|
22
34
|
:property_attributes,
|
35
|
+
:refund_attributes,
|
36
|
+
:refund_reason_attributes,
|
37
|
+
:reimbursement_attributes,
|
38
|
+
:reimbursement_type_attributes,
|
39
|
+
:report_attributes,
|
23
40
|
:return_authorization_attributes,
|
41
|
+
:return_authorization_reason_attributes,
|
42
|
+
:role_attributes,
|
24
43
|
:shipment_attributes,
|
44
|
+
:shipping_method_attributes,
|
45
|
+
:shipping_category_attributes,
|
25
46
|
:source_attributes,
|
26
47
|
:stock_item_attributes,
|
27
48
|
:stock_location_attributes,
|
28
49
|
:stock_movement_attributes,
|
50
|
+
:stock_transfer_attributes,
|
29
51
|
:store_attributes,
|
30
52
|
:store_credit_attributes,
|
53
|
+
:store_credit_category_attributes,
|
54
|
+
:tax_rate_attributes,
|
55
|
+
:tax_category_attributes,
|
31
56
|
:taxon_attributes,
|
32
57
|
:taxonomy_attributes,
|
58
|
+
:theme_attributes,
|
33
59
|
:user_attributes,
|
34
60
|
:variant_attributes,
|
35
61
|
:wishlist_attributes,
|
36
|
-
:wished_item_attributes
|
62
|
+
:wished_item_attributes,
|
63
|
+
:zone_attributes
|
37
64
|
]
|
38
65
|
|
39
66
|
mattr_reader(*ATTRIBUTES)
|
@@ -47,6 +74,8 @@ module Spree
|
|
47
74
|
state: [:name, :abbr] }
|
48
75
|
]
|
49
76
|
|
77
|
+
@@asset_attributes = [:type, :viewable_id, :viewable_type, :attachment, :alt, :position]
|
78
|
+
|
50
79
|
@@checkout_attributes = [
|
51
80
|
:coupon_code, :email, :shipping_method_id, :special_instructions, :use_billing, :use_shipping,
|
52
81
|
:user_id, :bill_address_id, :ship_address_id, :accept_marketing, :signup_for_an_account
|
@@ -60,6 +89,8 @@ module Spree
|
|
60
89
|
|
61
90
|
@@cms_section_attributes = [:name, :cms_page_id, :fit, :destination, { content: {}, settings: {} }]
|
62
91
|
|
92
|
+
@@custom_domain_attributes = [:url, :default]
|
93
|
+
|
63
94
|
@@customer_return_attributes = [:stock_location_id, {
|
64
95
|
return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount,
|
65
96
|
:acceptance_status, :exchange_variant_id, :resellable]
|
@@ -69,24 +100,39 @@ module Spree
|
|
69
100
|
|
70
101
|
@@digital_link_attributes = [:access_counter]
|
71
102
|
|
103
|
+
@@export_attributes = [:type, :format, :record_selection, search_params: {}]
|
104
|
+
|
72
105
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
73
106
|
|
107
|
+
@@integration_attributes = [:type, :active]
|
108
|
+
|
74
109
|
@@inventory_unit_attributes = [:shipment, :shipment_id, :variant_id]
|
75
110
|
|
111
|
+
@@invitation_attributes = [:email, :expires_at, :role_id]
|
112
|
+
|
76
113
|
@@line_item_attributes = [:id, :variant_id, :quantity]
|
77
114
|
|
78
115
|
@@menu_attributes = [:name, :locale, :location]
|
79
116
|
|
80
|
-
@@menu_item_attributes = [:name, :
|
117
|
+
@@menu_item_attributes = [:name, :subtitle, :destination, :new_window, :item_type,
|
81
118
|
:linked_resource_type, :linked_resource_id, :code, :menu_id]
|
82
119
|
|
83
|
-
@@option_type_attributes = [:name, :presentation, :
|
120
|
+
@@option_type_attributes = [:name, :presentation, :position, :filterable,
|
121
|
+
option_values_attributes: [:id, :name, :presentation, :position, :_destroy]]
|
122
|
+
|
123
|
+
@@option_value_attributes = [:name, :presentation, :position]
|
124
|
+
|
125
|
+
@@page_attributes = [:name, :slug, :meta_title, :meta_description, :meta_keywords]
|
126
|
+
|
127
|
+
@@page_link_attributes = [:linkable_id, :linkable_type, :position, :label, :url]
|
84
128
|
|
85
|
-
@@
|
129
|
+
@@page_section_attributes = [:type, :name, :position, :asset]
|
86
130
|
|
87
131
|
@@payment_attributes = [:amount, :payment_method_id, :payment_method]
|
88
132
|
|
89
|
-
@@
|
133
|
+
@@payment_method_attributes = [:name, :type, :description, :active, :display_on, :auto_capture, :position]
|
134
|
+
|
135
|
+
@@product_properties_attributes = [:property_name, :property_id, :value, :position, :_destroy]
|
90
136
|
|
91
137
|
@@product_attributes = [
|
92
138
|
:name, :description, :available_on, :make_active_at, :discontinue_on, :permalink, :meta_description,
|
@@ -94,24 +140,60 @@ module Spree
|
|
94
140
|
:option_values_hash, :weight, :height, :width, :depth,
|
95
141
|
:shipping_category_id, :tax_category_id,
|
96
142
|
:cost_currency, :cost_price, :compare_at_price,
|
97
|
-
:slug,
|
143
|
+
:slug, :track_inventory, :backorderable, :barcode, :status,
|
144
|
+
:weight_unit, :dimensions_unit,
|
98
145
|
{
|
99
146
|
tag_list: [],
|
147
|
+
label_list: [],
|
100
148
|
option_type_ids: [],
|
101
|
-
taxon_ids: []
|
149
|
+
taxon_ids: [],
|
150
|
+
store_ids: [],
|
151
|
+
product_option_types_attributes: [:id, :option_type_id, :position, :_destroy]
|
102
152
|
}
|
103
153
|
]
|
104
154
|
|
105
|
-
@@
|
155
|
+
@@promotion_attributes = [:name, :description, :starts_at, :expires_at, :code, :usage_limit, :path, :match_policy,
|
156
|
+
:advertise, :promotion_category_id, :code_prefix, :kind, :number_of_codes, :multi_codes, store_ids: []]
|
157
|
+
|
158
|
+
@@promotion_rule_attributes = [:type, :preferred_match_policy, user_ids_to_add: [], product_ids_to_add: [], taxon_ids_to_add: []]
|
159
|
+
|
160
|
+
@@promotion_action_attributes = [:type, :calculator_type, calculator_attributes: {}, promotion_action_line_items_attributes: [:id, :promotion_action_id, :variant_id, :quantity, :_destroy]]
|
161
|
+
|
162
|
+
@@property_attributes = [:name, :presentation, :position, :kind, :display_on]
|
163
|
+
|
164
|
+
@@refund_attributes = [:amount, :refund_reason_id]
|
165
|
+
|
166
|
+
@@refund_reason_attributes = [:name, :active, :mutable]
|
167
|
+
|
168
|
+
@@reimbursement_attributes = [return_items_attributes: [:id, :override_reimbursement_type_id, :pre_tax_amount, :exchange_variant_id]]
|
169
|
+
|
170
|
+
@@reimbursement_type_attributes = [:name, :active]
|
171
|
+
|
172
|
+
@@report_attributes = [:type, :date_from, :date_to, :currency]
|
106
173
|
|
107
174
|
@@return_authorization_attributes = [:amount, :memo, :stock_location_id, :inventory_units_attributes,
|
108
|
-
:return_authorization_reason_id
|
175
|
+
:return_authorization_reason_id, {
|
176
|
+
return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount,
|
177
|
+
:acceptance_status, :exchange_variant_id, :resellable]
|
178
|
+
}]
|
179
|
+
|
180
|
+
@@return_authorization_reason_attributes = [:name, :active]
|
181
|
+
|
182
|
+
@@return_item_attributes = [:inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id, :resellable]
|
183
|
+
|
184
|
+
@@role_attributes = [:name]
|
109
185
|
|
110
186
|
@@shipment_attributes = [
|
111
187
|
:order, :special_instructions, :stock_location_id, :id,
|
112
188
|
:tracking, :address, :inventory_units, :selected_shipping_rate_id
|
113
189
|
]
|
114
190
|
|
191
|
+
@@shipping_category_attributes = [:name]
|
192
|
+
|
193
|
+
@@shipping_method_attributes = [:name, :code,:tracking_url, :tax_category_id, :display_on,
|
194
|
+
:estimated_transit_business_days_min, :estimated_transit_business_days_max,
|
195
|
+
:calculator_type, :preferences, zone_ids: [], shipping_category_ids: [], calculator_attributes: {}]
|
196
|
+
|
115
197
|
# month / year may be provided by some sources, or others may elect to use one field
|
116
198
|
@@source_attributes = [
|
117
199
|
:id, :number, :month, :year, :expiry, :verification_value,
|
@@ -119,7 +201,7 @@ module Spree
|
|
119
201
|
:gateway_payment_profile_id, :last_digits, :name, :encrypted_data
|
120
202
|
]
|
121
203
|
|
122
|
-
@@stock_item_attributes = [:
|
204
|
+
@@stock_item_attributes = [:variant_id, :stock_location_id, :backorderable, :count_on_hand]
|
123
205
|
|
124
206
|
@@stock_location_attributes = [
|
125
207
|
:name, :active, :address1, :address2, :city, :zipcode,
|
@@ -131,6 +213,9 @@ module Spree
|
|
131
213
|
:quantity, :stock_item, :stock_item_id, :originator, :action
|
132
214
|
]
|
133
215
|
|
216
|
+
@@stock_transfer_attributes = [:source_location_id, :destination_location_id, :reference,
|
217
|
+
stock_movements_attributes: [:variant_id, :quantity, :originator_id, :stock_item_id]]
|
218
|
+
|
134
219
|
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords,
|
135
220
|
:meta_description, :default_currency, :mail_from_address,
|
136
221
|
:customer_support_email, :description, :address, :contact_phone,
|
@@ -148,25 +233,36 @@ module Spree
|
|
148
233
|
|
149
234
|
@@store_credit_attributes = %i[amount currency category_id memo]
|
150
235
|
|
236
|
+
@@store_credit_category_attributes = [:name]
|
237
|
+
|
151
238
|
@@taxonomy_attributes = [:name]
|
152
239
|
|
240
|
+
@@tax_category_attributes = [:name, :tax_code,:description, :is_default]
|
241
|
+
|
242
|
+
@@tax_rate_attributes = [:name, :amount, :zone_id, :tax_category_id, :included_in_price, :show_rate_in_label, :calculator_type, calculator_attributes: {}]
|
243
|
+
|
153
244
|
@@taxon_attributes = [
|
154
245
|
:name, :parent_id, :position, :icon, :description, :permalink, :hide_from_nav,
|
155
|
-
:taxonomy_id, :meta_description, :meta_keywords, :meta_title, :child_index
|
246
|
+
:taxonomy_id, :meta_description, :meta_keywords, :meta_title, :child_index,
|
247
|
+
:automatic, :rules_match_policy, :sort_order,
|
248
|
+
:image, :square_image, :description,
|
249
|
+
taxon_rules_attributes: [:id, :type, :value, :match_policy, :_destroy],
|
156
250
|
]
|
157
251
|
|
252
|
+
@@theme_attributes = [:name, :type, :default]
|
253
|
+
|
158
254
|
@@user_attributes = [:email, :bill_address_id, :ship_address_id, :password, :first_name, :last_name,
|
159
255
|
:password_confirmation, :selected_locale, :avatar, :accepts_email_marketing, :phone,
|
160
256
|
{ public_metadata: {}, private_metadata: {}, tag_list: [] }]
|
161
257
|
|
162
258
|
@@variant_attributes = [
|
163
259
|
:name, :presentation, :cost_price, :discontinue_on, :lock_version,
|
164
|
-
:position, :track_inventory,
|
260
|
+
:position, :track_inventory, :tax_category_id,
|
165
261
|
:product_id, :product, :option_values_attributes, :price, :compare_at_price,
|
166
262
|
:weight, :height, :width, :depth, :sku, :barcode, :cost_currency,
|
167
263
|
:weight_unit, :dimensions_unit,
|
168
264
|
{
|
169
|
-
options: [:id, :name, :
|
265
|
+
options: [:id, :name, :value, :position, :_destroy],
|
170
266
|
stock_items_attributes: [:id, :count_on_hand, :stock_location_id, :backorderable, :_destroy],
|
171
267
|
prices_attributes: [:id, :amount, :compare_at_amount, :currency, :_destroy],
|
172
268
|
price: {},
|
@@ -178,5 +274,7 @@ module Spree
|
|
178
274
|
@@wishlist_attributes = [:name, :is_default, :is_private]
|
179
275
|
|
180
276
|
@@wished_item_attributes = [:variant_id, :quantity]
|
277
|
+
|
278
|
+
@@zone_attributes = [:name, :description, :default_tax, :kind, :states_country_id, country_ids: [], state_ids: []]
|
181
279
|
end
|
182
280
|
end
|
@@ -46,39 +46,21 @@ namespace :common do
|
|
46
46
|
"--authentication=#{args[:authentication]}"
|
47
47
|
]
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
unless ENV['NO_MIGRATE']
|
55
|
-
puts 'Setting up dummy database...'
|
56
|
-
system('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')
|
57
|
-
system('bundle exec rake db:drop db:create > /dev/null 2>&1')
|
58
|
-
Spree::DummyModelGenerator.start
|
59
|
-
system('bundle exec rake db:migrate > /dev/null 2>&1')
|
60
|
-
end
|
49
|
+
puts 'Setting up dummy database...'
|
50
|
+
system('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')
|
51
|
+
system('bundle exec rake db:drop db:create > /dev/null 2>&1')
|
52
|
+
Spree::DummyModelGenerator.start
|
53
|
+
system('bundle exec rake db:migrate > /dev/null 2>&1')
|
61
54
|
|
62
55
|
begin
|
63
56
|
require "generators/#{ENV['LIB_NAME']}/install/install_generator"
|
64
57
|
puts 'Running extension installation generator...'
|
65
|
-
|
66
|
-
if ENV['NO_MIGRATE']
|
67
|
-
"#{ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start([])
|
68
|
-
else
|
69
|
-
"#{ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start(['--auto-run-migrations'])
|
70
|
-
end
|
58
|
+
"#{ENV['LIB_NAME'].camelize}::Generators::InstallGenerator".constantize.start(['--auto-run-migrations'])
|
71
59
|
rescue LoadError
|
72
60
|
puts 'Skipping installation no generator to run...'
|
73
61
|
end
|
74
|
-
end
|
75
62
|
|
76
|
-
|
77
|
-
puts 'Setting up dummy database...'
|
78
|
-
system('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')
|
79
|
-
system('bundle exec rake db:drop db:create > /dev/null 2>&1')
|
80
|
-
Spree::DummyModelGenerator.start
|
81
|
-
system('bundle exec rake db:migrate > /dev/null 2>&1')
|
63
|
+
system('bundle exec rake assets:precompile > /dev/null 2>&1') if !skip_javascript || ENV['LIB_NAME'] == 'spree/emails'
|
82
64
|
end
|
83
65
|
|
84
66
|
task :seed do |_t|
|
@@ -2,7 +2,7 @@ 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, [:user_class] do |_t, args|
|
6
6
|
Spree::DummyGeneratorHelper.inject_extension_requirements = true
|
7
7
|
Rake::Task['common:test_app'].execute(args.with_defaults(install_admin: true, install_storefront: true))
|
8
8
|
end
|
@@ -20,9 +20,5 @@ FactoryBot.define do
|
|
20
20
|
factory :newsletter_page_section, class: Spree::PageSections::Newsletter
|
21
21
|
|
22
22
|
factory :video_page_section, class: Spree::PageSections::Video
|
23
|
-
|
24
|
-
factory :image_with_text_page_section, class: Spree::PageSections::ImageWithText
|
25
|
-
|
26
|
-
factory :featured_posts_page_section, class: Spree::PageSections::FeaturedPosts
|
27
23
|
end
|
28
24
|
end
|
@@ -14,11 +14,6 @@ FactoryBot.define do
|
|
14
14
|
create(:refund, amount: 5, payment: payment)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
|
-
factory :custom_payment, class: Spree::Payment do
|
19
|
-
payment_method { create(:custom_payment_method, stores: [order.store]) }
|
20
|
-
source { create(:payment_source, user: order.user, payment_method: payment_method) }
|
21
|
-
end
|
22
17
|
end
|
23
18
|
|
24
19
|
factory :check_payment, class: Spree::Payment do
|
@@ -37,9 +37,4 @@ FactoryBot.define do
|
|
37
37
|
active { true }
|
38
38
|
auto_capture { true }
|
39
39
|
end
|
40
|
-
|
41
|
-
factory :custom_payment_method, parent: :payment_method, class: Spree::Gateway::CustomPaymentSourceMethod do
|
42
|
-
type { 'Spree::Gateway::CustomPaymentSourceMethod' }
|
43
|
-
name { 'Custom' }
|
44
|
-
end
|
45
40
|
end
|
@@ -9,12 +9,6 @@ FactoryBot.define do
|
|
9
9
|
trait :with_description do
|
10
10
|
description { '<div>Test <strong>description</strong></div>' }
|
11
11
|
end
|
12
|
-
|
13
|
-
trait :with_header_image do
|
14
|
-
after(:create) do |taxon|
|
15
|
-
taxon.image.attach(io: File.new(Spree::Core::Engine.root.join('spec', 'fixtures', 'thinking-cat.jpg')), filename: 'thinking-cat.jpg')
|
16
|
-
end
|
17
|
-
end
|
18
12
|
end
|
19
13
|
|
20
14
|
factory :automatic_taxon, parent: :taxon do
|
@@ -30,6 +30,19 @@ FactoryBot.define do
|
|
30
30
|
first_name { FFaker::Name.first_name }
|
31
31
|
last_name { FFaker::Name.last_name }
|
32
32
|
|
33
|
-
|
33
|
+
transient do
|
34
|
+
without_admin_role { false }
|
35
|
+
end
|
36
|
+
|
37
|
+
trait :without_admin_role do
|
38
|
+
without_admin_role { true }
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:create) do |user, evaluator|
|
42
|
+
unless evaluator.without_admin_role
|
43
|
+
admin_role = Spree::Role.default_admin_role
|
44
|
+
create(:role_user, user: user, role: admin_role) unless user.has_spree_role?(admin_role.name)
|
45
|
+
end
|
46
|
+
end
|
34
47
|
end
|
35
48
|
end
|
@@ -12,14 +12,24 @@ module Spree
|
|
12
12
|
nullify_translatable_fields = @resource_class.translatable_fields.map { |f| "#{f}=null" }.join(', ')
|
13
13
|
|
14
14
|
unless @resource_class::Translation.exists?
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
# Copy data from main table to translations table
|
16
|
+
@resource_class.find_each do |resource|
|
17
|
+
translation_attrs = @resource_class.translatable_fields.each_with_object({}) do |field, attrs|
|
18
|
+
attrs[field] = resource[field]
|
19
|
+
end
|
20
|
+
|
21
|
+
@resource_class::Translation.create!(
|
22
|
+
translation_attrs.merge(
|
23
|
+
@foreign_key => resource.id,
|
24
|
+
locale: @default_locale,
|
25
|
+
created_at: resource.created_at,
|
26
|
+
updated_at: resource.updated_at
|
27
|
+
)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Nullify translatable fields in main table
|
32
|
+
@resource_class.update_all(nullify_translatable_fields)
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|
@@ -27,14 +37,16 @@ module Spree
|
|
27
37
|
translation_table_fields = @resource_class.translatable_fields.map { |f| "#{@translations_table}.#{f}" }.join(', ')
|
28
38
|
row_expression = @resource_class.translatable_fields.count == 1 ? 'ROW' : ''
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
# Update main table with translations
|
41
|
+
@resource_class::Translation.find_each do |translation|
|
42
|
+
resource = @resource_class.find(translation[@foreign_key])
|
43
|
+
@resource_class.translatable_fields.each do |field|
|
44
|
+
resource.update_column(field, translation[field])
|
45
|
+
end
|
46
|
+
end
|
36
47
|
|
37
|
-
|
48
|
+
# Clear translations table
|
49
|
+
@resource_class::Translation.delete_all
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
data/lib/tasks/core.rake
CHANGED
@@ -184,6 +184,14 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
end
|
187
|
+
|
188
|
+
task migrate_admin_users_to_role_users: :environment do |_t, _args|
|
189
|
+
Spree.admin_user_class.all.each do |admin_user|
|
190
|
+
Spree::Store.all.each do |store|
|
191
|
+
store.add_user(admin_user)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
187
195
|
end
|
188
196
|
|
189
197
|
namespace :core do
|