solidus_core 2.11.7 → 2.11.11
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/models/concerns/spree/active_storage_adapter/attachment.rb +11 -11
- data/app/models/concerns/spree/active_storage_adapter.rb +2 -0
- data/app/models/spree/base.rb +38 -20
- data/app/models/spree/calculator.rb +4 -0
- data/app/models/spree/image/active_storage_attachment.rb +10 -2
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/order.rb +1 -1
- data/app/models/spree/payment/cancellation.rb +22 -3
- data/app/models/spree/payment_method/bogus_credit_card.rb +13 -9
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
- data/app/models/spree/payment_method.rb +3 -0
- data/app/models/spree/product.rb +0 -1
- data/app/models/spree/promotion_action.rb +3 -0
- data/app/models/spree/promotion_rule.rb +4 -0
- data/app/models/spree/refund.rb +5 -3
- data/app/models/spree/stock/simple_coordinator.rb +6 -1
- data/app/models/spree/variant.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +1 -1
- data/lib/spree/app_configuration.rb +8 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/permitted_attributes.rb +7 -1
- data/lib/spree/preferences/persistable.rb +23 -0
- data/lib/spree/testing_support/dummy_app.rb +1 -0
- data/lib/spree/testing_support/fixtures/file.txt +1 -0
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +15 -20
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a612b396e4f6bd4624851ca8c6a234c6cc1628c8e6edf889d62fb57830b452a2
|
4
|
+
data.tar.gz: 95129bf8b5ad056d9356b63b4a89eaf36697208d16035e84b7627d8d3a710996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3b3f8246277100e2b3f9f71edca05cd76a1352e851cff75a36c68f7eb8107485ac7d258a0ea15703e3e7582542c24aef1d0201e9d3697b6fbbe80e6315581c
|
7
|
+
data.tar.gz: 219847c0d55e4b02063c69e32a7a0a0399600d083ab915c707722be181f87a591b87a2245e241ba77cee23253ca869228e638eecb8d3ebceb17e67371a125f05
|
@@ -9,11 +9,9 @@ module Spree
|
|
9
9
|
class Attachment
|
10
10
|
delegate_missing_to :@attachment
|
11
11
|
|
12
|
-
DEFAULT_SIZE = '100%'
|
13
|
-
|
14
12
|
def initialize(attachment, styles: {})
|
15
13
|
@attachment = attachment
|
16
|
-
@styles = styles
|
14
|
+
@styles = normalize_styles(styles)
|
17
15
|
end
|
18
16
|
|
19
17
|
def exists?
|
@@ -21,20 +19,18 @@ module Spree
|
|
21
19
|
end
|
22
20
|
|
23
21
|
def filename
|
24
|
-
blob
|
22
|
+
blob&.filename.to_s
|
25
23
|
end
|
26
24
|
|
27
25
|
def url(style = nil)
|
28
|
-
variant(style)
|
26
|
+
variant(style)&.url
|
29
27
|
end
|
30
28
|
|
31
29
|
def variant(style = nil)
|
32
|
-
size = style_to_size(style
|
30
|
+
size = style_to_size(style)
|
33
31
|
@attachment.variant(
|
34
|
-
|
35
|
-
strip: true
|
36
|
-
'auto-orient': true,
|
37
|
-
colorspace: 'sRGB',
|
32
|
+
resize_to_limit: size,
|
33
|
+
strip: true
|
38
34
|
).processed
|
39
35
|
end
|
40
36
|
|
@@ -61,8 +57,12 @@ module Spree
|
|
61
57
|
@attachment.metadata
|
62
58
|
end
|
63
59
|
|
60
|
+
def normalize_styles(styles)
|
61
|
+
styles.transform_values { |v| v.split('x') }
|
62
|
+
end
|
63
|
+
|
64
64
|
def style_to_size(style)
|
65
|
-
@styles.fetch(style) {
|
65
|
+
@styles.fetch(style&.to_sym) { [width, height] }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/app/models/spree/base.rb
CHANGED
@@ -1,28 +1,50 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
4
|
+
|
3
5
|
class Spree::Base < ActiveRecord::Base
|
4
|
-
include Spree::Preferences::Preferable
|
5
6
|
include Spree::Core::Permalinks
|
6
7
|
include Spree::RansackableAttributes
|
7
8
|
|
8
|
-
def
|
9
|
-
|
9
|
+
def self.preference(*args)
|
10
|
+
Spree::Deprecation.warn <<~WARN
|
11
|
+
#{name} has a `preferences` column, but does not explicitly (de)serialize this column.
|
12
|
+
In order to make #{name} work with future versions of Solidus (and Rails), please add the
|
13
|
+
following line to your class:
|
14
|
+
```
|
15
|
+
class #{name}
|
16
|
+
include Spree::Preferences::Persistable
|
17
|
+
...
|
18
|
+
end
|
19
|
+
```
|
20
|
+
WARN
|
21
|
+
include Spree::Preferences::Persistable
|
22
|
+
preference(*args)
|
10
23
|
end
|
11
24
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
def preferences
|
26
|
+
value = read_attribute(:preferences)
|
27
|
+
if !value.is_a?(Hash)
|
28
|
+
Spree::Deprecation.warn <<~WARN
|
29
|
+
#{self.class.name} has a `preferences` column, but does not explicitly (de)serialize this column.
|
30
|
+
In order to make #{self.class.name} work with future versions of Solidus (and Rails), please add the
|
31
|
+
following lines to your class:
|
32
|
+
```
|
33
|
+
class #{self.class.name}
|
34
|
+
include Spree::Preferences::Persistable
|
35
|
+
...
|
36
|
+
end
|
37
|
+
```
|
38
|
+
WARN
|
39
|
+
self.class.include Spree::Preferences::Persistable
|
17
40
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
super
|
41
|
+
ActiveRecord::Type::Serialized.new(
|
42
|
+
ActiveRecord::Type::Text.new,
|
43
|
+
ActiveRecord::Coders::YAMLColumn.new(:preferences, Hash)
|
44
|
+
).deserialize(value)
|
45
|
+
else
|
46
|
+
value
|
47
|
+
end
|
26
48
|
end
|
27
49
|
|
28
50
|
if Kaminari.config.page_method_name != :page
|
@@ -35,10 +57,6 @@ class Spree::Base < ActiveRecord::Base
|
|
35
57
|
end
|
36
58
|
end
|
37
59
|
|
38
|
-
def self.preferences_coder_class
|
39
|
-
Hash
|
40
|
-
end
|
41
|
-
|
42
60
|
self.abstract_class = true
|
43
61
|
|
44
62
|
# Provides a scope that should be included any time products
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
4
|
+
|
3
5
|
module Spree
|
4
6
|
class Calculator < Spree::Base
|
7
|
+
include Spree::Preferences::Persistable
|
8
|
+
|
5
9
|
belongs_to :calculable, polymorphic: true, optional: true
|
6
10
|
|
7
11
|
# This method calls a compute_<computable> method. must be overriden in concrete calculator.
|
@@ -7,6 +7,10 @@ module Spree::Image::ActiveStorageAttachment
|
|
7
7
|
delegate :width, :height, to: :attachment, prefix: true
|
8
8
|
|
9
9
|
included do
|
10
|
+
validates :attachment, presence: true
|
11
|
+
validate :attachment_is_an_image
|
12
|
+
validate :supported_content_type
|
13
|
+
|
10
14
|
has_attachment :attachment,
|
11
15
|
styles: {
|
12
16
|
mini: '48x48>',
|
@@ -15,7 +19,11 @@ module Spree::Image::ActiveStorageAttachment
|
|
15
19
|
large: '1200x1200>'
|
16
20
|
},
|
17
21
|
default_style: :product
|
18
|
-
|
19
|
-
|
22
|
+
|
23
|
+
def supported_content_type
|
24
|
+
unless attachment.content_type.in?(Spree::Config.allowed_image_mime_types)
|
25
|
+
errors.add(:attachment, :content_type_not_supported)
|
26
|
+
end
|
27
|
+
end
|
20
28
|
end
|
21
29
|
end
|
@@ -15,7 +15,7 @@ module Spree::Image::PaperclipAttachment
|
|
15
15
|
convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
|
16
16
|
validates_attachment :attachment,
|
17
17
|
presence: true,
|
18
|
-
content_type: { content_type:
|
18
|
+
content_type: { content_type: Spree::Config.allowed_image_mime_types }
|
19
19
|
|
20
20
|
# save the w,h of the original image (from which others can be calculated)
|
21
21
|
# we need to look at the write-queue for images which have not been saved yet
|
data/app/models/spree/order.rb
CHANGED
@@ -584,7 +584,7 @@ module Spree
|
|
584
584
|
raise CannotRebuildShipments.new(I18n.t('spree.cannot_rebuild_shipments_shipments_not_pending'))
|
585
585
|
else
|
586
586
|
shipments.destroy_all
|
587
|
-
|
587
|
+
shipments.push(*Spree::Config.stock.coordinator_class.new(self).shipments)
|
588
588
|
end
|
589
589
|
end
|
590
590
|
|
@@ -26,10 +26,16 @@ module Spree
|
|
26
26
|
# @param payment [Spree::Payment] - the payment that should be canceled
|
27
27
|
#
|
28
28
|
def cancel(payment)
|
29
|
-
|
30
|
-
|
29
|
+
# For payment methods already implemeting `try_void`
|
30
|
+
if try_void_available?(payment.payment_method)
|
31
|
+
if response = payment.payment_method.try_void(payment)
|
32
|
+
payment.handle_void_response(response)
|
33
|
+
else
|
34
|
+
payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
|
35
|
+
end
|
31
36
|
else
|
32
|
-
|
37
|
+
# For payment methods not yet implemeting `try_void`
|
38
|
+
deprecated_behavior(payment)
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -38,6 +44,19 @@ module Spree
|
|
38
44
|
def refund_reason
|
39
45
|
Spree::RefundReason.where(name: reason).first_or_create
|
40
46
|
end
|
47
|
+
|
48
|
+
def try_void_available?(payment_method)
|
49
|
+
payment_method.respond_to?(:try_void) &&
|
50
|
+
payment_method.method(:try_void).owner != Spree::PaymentMethod
|
51
|
+
end
|
52
|
+
|
53
|
+
def deprecated_behavior(payment)
|
54
|
+
Spree::Deprecation.warn "#{payment.payment_method.class.name}#cancel is deprecated and will be removed. " \
|
55
|
+
'Please implement a `try_void` method instead that returns a response object if void succeeds ' \
|
56
|
+
'or `false|nil` if not. Solidus will refund the payment then.'
|
57
|
+
response = payment.payment_method.cancel(payment.response_code)
|
58
|
+
payment.handle_void_response(response)
|
59
|
+
end
|
41
60
|
end
|
42
61
|
end
|
43
62
|
end
|
@@ -9,6 +9,10 @@ module Spree
|
|
9
9
|
|
10
10
|
VALID_CCS = ['1', TEST_VISA, TEST_MC, TEST_AMEX, TEST_DISC].flatten
|
11
11
|
|
12
|
+
AUTHORIZATION_CODE = '12345'
|
13
|
+
FAILURE_MESSAGE = 'Bogus Gateway: Forced failure'
|
14
|
+
SUCCESS_MESSAGE = 'Bogus Gateway: Forced success'
|
15
|
+
|
12
16
|
attr_accessor :test
|
13
17
|
|
14
18
|
def gateway_class
|
@@ -26,40 +30,40 @@ module Spree
|
|
26
30
|
def authorize(_money, credit_card, _options = {})
|
27
31
|
profile_id = credit_card.gateway_customer_profile_id
|
28
32
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
29
|
-
ActiveMerchant::Billing::Response.new(true,
|
33
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'D' })
|
30
34
|
else
|
31
|
-
ActiveMerchant::Billing::Response.new(false,
|
35
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, test: true)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def purchase(_money, credit_card, _options = {})
|
36
40
|
profile_id = credit_card.gateway_customer_profile_id
|
37
41
|
if VALID_CCS.include?(credit_card.number) || (profile_id && profile_id.starts_with?('BGS-'))
|
38
|
-
ActiveMerchant::Billing::Response.new(true,
|
42
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'M' })
|
39
43
|
else
|
40
|
-
ActiveMerchant::Billing::Response.new(false,
|
44
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def credit(_money, _credit_card, _response_code, _options = {})
|
45
|
-
ActiveMerchant::Billing::Response.new(true,
|
49
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
46
50
|
end
|
47
51
|
|
48
52
|
def capture(_money, authorization, _gateway_options)
|
49
53
|
if authorization == '12345'
|
50
|
-
ActiveMerchant::Billing::Response.new(true,
|
54
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true)
|
51
55
|
else
|
52
|
-
ActiveMerchant::Billing::Response.new(false,
|
56
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, error: FAILURE_MESSAGE, test: true)
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def void(_response_code, _credit_card, _options = {})
|
57
|
-
ActiveMerchant::Billing::Response.new(true,
|
61
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
58
62
|
end
|
59
63
|
|
60
64
|
# @see Spree::PaymentMethod#try_void
|
61
65
|
def try_void(_payment)
|
62
|
-
ActiveMerchant::Billing::Response.new(true,
|
66
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE)
|
63
67
|
end
|
64
68
|
|
65
69
|
def test?
|
@@ -9,17 +9,17 @@ module Spree
|
|
9
9
|
|
10
10
|
def authorize(_money, credit_card, _options = {})
|
11
11
|
if VALID_CCS.include? credit_card.number
|
12
|
-
ActiveMerchant::Billing::Response.new(true,
|
12
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
|
13
13
|
else
|
14
|
-
ActiveMerchant::Billing::Response.new(false,
|
14
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, { message: FAILURE_MESSAGE }, test: true)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def purchase(_money, credit_card, _options = {})
|
19
19
|
if VALID_CCS.include? credit_card.number
|
20
|
-
ActiveMerchant::Billing::Response.new(true,
|
20
|
+
ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
|
21
21
|
else
|
22
|
-
ActiveMerchant::Billing::Response.new(false,
|
22
|
+
ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE, message: FAILURE_MESSAGE, test: true)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
3
4
|
require 'spree/preferences/statically_configurable'
|
4
5
|
|
5
6
|
module Spree
|
@@ -11,6 +12,8 @@ module Spree
|
|
11
12
|
# This class is not meant to be instantiated. Please create instances of concrete payment methods.
|
12
13
|
#
|
13
14
|
class PaymentMethod < Spree::Base
|
15
|
+
include Spree::Preferences::Persistable
|
16
|
+
|
14
17
|
preference :server, :string, default: 'test'
|
15
18
|
preference :test_mode, :boolean, default: true
|
16
19
|
|
data/app/models/spree/product.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
4
|
+
|
3
5
|
module Spree
|
4
6
|
# Base class for all types of promotion action.
|
5
7
|
#
|
6
8
|
# PromotionActions perform the necessary tasks when a promotion is activated
|
7
9
|
# by an event and determined to be eligible.
|
8
10
|
class PromotionAction < Spree::Base
|
11
|
+
include Spree::Preferences::Persistable
|
9
12
|
include Spree::SoftDeletable
|
10
13
|
|
11
14
|
belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_actions, optional: true
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spree/preferences/persistable'
|
4
|
+
|
3
5
|
module Spree
|
4
6
|
# Base class for all promotion rules
|
5
7
|
class PromotionRule < Spree::Base
|
8
|
+
include Spree::Preferences::Persistable
|
9
|
+
|
6
10
|
belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_rules, optional: true
|
7
11
|
|
8
12
|
scope :of_type, ->(type) { where(type: type) }
|
data/app/models/spree/refund.rb
CHANGED
@@ -48,6 +48,10 @@ module Spree
|
|
48
48
|
return true if perform_after_create == false
|
49
49
|
return true if transaction_id.present?
|
50
50
|
|
51
|
+
# This is needed otherwise set_perform_after_create_default callback
|
52
|
+
# will print a deprecation warning when save! creates a record
|
53
|
+
self.perform_after_create = false unless persisted?
|
54
|
+
|
51
55
|
credit_cents = money.cents
|
52
56
|
|
53
57
|
@perform_response = process!(credit_cents)
|
@@ -63,9 +67,7 @@ module Spree
|
|
63
67
|
log_entries.build(details: perform_response.to_yaml)
|
64
68
|
|
65
69
|
self.transaction_id = perform_response.authorization
|
66
|
-
|
67
|
-
# will print a deprecation warning when save! creates a record.
|
68
|
-
self.perform_after_create = false unless persisted?
|
70
|
+
|
69
71
|
save!
|
70
72
|
|
71
73
|
update_order
|
@@ -73,11 +73,16 @@ module Spree
|
|
73
73
|
packages = split_packages(packages)
|
74
74
|
|
75
75
|
# Turn the Stock::Packages into a Shipment with rates
|
76
|
-
packages.map do |package|
|
76
|
+
shipments = packages.map do |package|
|
77
77
|
shipment = package.shipment = package.to_shipment
|
78
78
|
shipment.shipping_rates = Spree::Config.stock.estimator_class.new.shipping_rates(package)
|
79
79
|
shipment
|
80
80
|
end
|
81
|
+
|
82
|
+
# Make sure we don't add the proposed shipments to the order
|
83
|
+
order.shipments = order.shipments - shipments
|
84
|
+
|
85
|
+
shipments
|
81
86
|
end
|
82
87
|
|
83
88
|
def split_packages(initial_packages)
|
data/app/models/spree/variant.rb
CHANGED
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
attr_writer :rebuild_vat_prices
|
31
31
|
include Spree::DefaultPrice
|
32
32
|
|
33
|
-
belongs_to :product, -> { with_discarded }, touch: true, class_name: 'Spree::Product', inverse_of: :
|
33
|
+
belongs_to :product, -> { with_discarded }, touch: true, class_name: 'Spree::Product', inverse_of: :variants_including_master, optional: false
|
34
34
|
belongs_to :tax_category, class_name: 'Spree::TaxCategory', optional: true
|
35
35
|
|
36
36
|
delegate :name, :description, :slug, :available_on, :discontinue_on, :discontinued?,
|
@@ -171,7 +171,7 @@ module Solidus
|
|
171
171
|
end
|
172
172
|
|
173
173
|
bundle_cleanly{ run "bundle install" } if @plugins_to_be_installed.any?
|
174
|
-
run "spring stop"
|
174
|
+
run "spring stop" if defined?(Spring)
|
175
175
|
|
176
176
|
@plugin_generators_to_run.each do |plugin_generator_name|
|
177
177
|
generate "#{plugin_generator_name} --skip_migrations=false"
|
@@ -504,6 +504,14 @@ module Spree
|
|
504
504
|
# Enumerable of images adhering to the present_image_class interface
|
505
505
|
class_name_attribute :image_attachment_module, default: 'Spree::Image::PaperclipAttachment'
|
506
506
|
|
507
|
+
# @!attribute [rw] allowed_image_mime_types
|
508
|
+
#
|
509
|
+
# Defines which MIME types are allowed for images
|
510
|
+
# `%w(image/jpeg image/jpg image/png image/gif).freeze` is the default.
|
511
|
+
#
|
512
|
+
# @return [Array]
|
513
|
+
class_name_attribute :allowed_image_mime_types, default: %w(image/jpeg image/jpg image/png image/gif).freeze
|
514
|
+
|
507
515
|
# Allows switching attachment library for Taxon
|
508
516
|
#
|
509
517
|
# `Spree::Taxon::PaperclipAttachment`
|
data/lib/spree/core/version.rb
CHANGED
@@ -52,7 +52,13 @@ module Spree
|
|
52
52
|
:month, :year, :expiry, :first_name, :last_name, :name
|
53
53
|
]
|
54
54
|
|
55
|
-
@@customer_return_attributes = [
|
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
|
+
]
|
56
62
|
|
57
63
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
58
64
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Preferences
|
5
|
+
module Persistable
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
include Spree::Preferences::Preferable
|
10
|
+
serialize :preferences, Hash
|
11
|
+
after_initialize :initialize_preference_defaults
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def initialize_preference_defaults
|
17
|
+
if has_attribute?(:preferences)
|
18
|
+
self.preferences = default_preferences.merge(preferences)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a text file
|
@@ -3,34 +3,29 @@
|
|
3
3
|
namespace :solidus do
|
4
4
|
namespace :migrations do
|
5
5
|
namespace :migrate_default_billing_addresses_to_address_book do
|
6
|
-
task up: :environment do
|
7
|
-
|
6
|
+
task :up, [:batch_size] => [:environment] do |_t, args|
|
7
|
+
batch_size = args[:batch_size] || 100_000
|
8
|
+
print "Migrating default billing addresses to address book in batches of #{batch_size} ... "
|
8
9
|
if Spree::UserAddress.where(default_billing: true).any?
|
9
|
-
Spree.user_class.joins(:bill_address).
|
10
|
+
Spree.user_class.joins(:bill_address).in_batches(of: batch_size).each do |batch|
|
11
|
+
batch.update_all(bill_address_id: nil) # rubocop:disable Rails/SkipsModelValidations
|
12
|
+
end
|
10
13
|
end
|
11
|
-
|
12
|
-
|
13
|
-
sql = <<~SQL
|
14
|
-
UPDATE spree_user_addresses
|
14
|
+
Spree::UserAddress.joins(
|
15
|
+
<<~SQL
|
15
16
|
JOIN spree_users ON spree_user_addresses.user_id = spree_users.id
|
16
|
-
|
17
|
-
SET spree_user_addresses.default_billing = true
|
18
|
-
SQL
|
19
|
-
else
|
20
|
-
sql = <<~SQL
|
21
|
-
UPDATE spree_user_addresses
|
22
|
-
SET default_billing = true
|
23
|
-
FROM spree_users
|
24
|
-
WHERE spree_user_addresses.address_id = spree_users.bill_address_id
|
25
|
-
AND spree_user_addresses.user_id = spree_users.id;
|
17
|
+
AND spree_user_addresses.address_id = spree_users.bill_address_id
|
26
18
|
SQL
|
19
|
+
).in_batches(of: batch_size).each do |batch|
|
20
|
+
batch.update_all(default_billing: true) # rubocop:disable Rails/SkipsModelValidations
|
27
21
|
end
|
28
|
-
|
22
|
+
|
29
23
|
puts "Success"
|
30
24
|
end
|
31
25
|
|
32
|
-
task down: :environment do
|
33
|
-
|
26
|
+
task :down, [:batch_size] => [:environment] do |_t, args|
|
27
|
+
batch_size = args[:batch_size] || 100_000
|
28
|
+
Spree::UserAddress.in_batches(of: batch_size).update_all(default_billing: false) # rubocop:disable Rails/SkipsModelValidations
|
34
29
|
puts "Rolled back default billing address migration to address book"
|
35
30
|
end
|
36
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -829,6 +829,7 @@ files:
|
|
829
829
|
- lib/spree/permission_sets/user_management.rb
|
830
830
|
- lib/spree/permitted_attributes.rb
|
831
831
|
- lib/spree/preferences/configuration.rb
|
832
|
+
- lib/spree/preferences/persistable.rb
|
832
833
|
- lib/spree/preferences/preferable.rb
|
833
834
|
- lib/spree/preferences/preferable_class_methods.rb
|
834
835
|
- lib/spree/preferences/scoped_store.rb
|
@@ -918,6 +919,7 @@ files:
|
|
918
919
|
- lib/spree/testing_support/factories/zone_factory.rb
|
919
920
|
- lib/spree/testing_support/factory_bot.rb
|
920
921
|
- lib/spree/testing_support/fixtures/blank.jpg
|
922
|
+
- lib/spree/testing_support/fixtures/file.txt
|
921
923
|
- lib/spree/testing_support/flash.rb
|
922
924
|
- lib/spree/testing_support/job_helpers.rb
|
923
925
|
- lib/spree/testing_support/order_walkthrough.rb
|
@@ -983,7 +985,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
983
985
|
- !ruby/object:Gem::Version
|
984
986
|
version: 1.8.23
|
985
987
|
requirements: []
|
986
|
-
rubygems_version: 3.
|
988
|
+
rubygems_version: 3.2.20
|
987
989
|
signing_key:
|
988
990
|
specification_version: 4
|
989
991
|
summary: Essential models, mailers, and classes for the Solidus e-commerce project.
|