solidus_core 3.0.0.rc2 → 3.0.3
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 +0 -17
- 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_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/return_item.rb +2 -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/engine.rb +8 -0
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/deprecation.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/spree/testing_support.rb +1 -1
- data/lib/tasks/upgrade.rake +7 -5
- data/solidus_core.gemspec +20 -0
- metadata +25 -8
- data/lib/tasks/migrations/migrate_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62f37b6c4bf7750e3089c0222694e5c742dbd7c808c8bc6436b75b8748630902
|
4
|
+
data.tar.gz: e6e1cf743d272aa97105886dadf319f1b5f87d40f918c8f01860b2e9b7ed398a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f313251388f99f58497196bb6698faa2068dc2a08c655e92a1a038f0a893eacc3d6ee4ac6b5d2780f49e484671978b3260799e77662aa1baa32b10490c93fd5
|
7
|
+
data.tar.gz: caada3471120a64a10f44378c9ee207d4c791914437e46671c6e22f0eaecc42d81885571b743e71034b8b2f466d4f9f624e64dbefac12211225b61978534392b
|
@@ -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,26 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Spree::Base < ActiveRecord::Base
|
4
|
-
include Spree::Preferences::Preferable
|
5
4
|
include Spree::Core::Permalinks
|
6
5
|
include Spree::RansackableAttributes
|
7
6
|
|
8
|
-
def initialize_preference_defaults
|
9
|
-
if has_attribute?(:preferences)
|
10
|
-
self.preferences = default_preferences.merge(preferences)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Only run preference initialization on models which requires it. Improves
|
15
|
-
# performance of record initialization slightly.
|
16
|
-
def self.preference(*args)
|
17
|
-
# after_initialize can be called multiple times with the same symbol, it
|
18
|
-
# will only be called once on initialization.
|
19
|
-
serialize :preferences, Hash
|
20
|
-
after_initialize :initialize_preference_defaults
|
21
|
-
super
|
22
|
-
end
|
23
|
-
|
24
7
|
self.abstract_class = true
|
25
8
|
|
26
9
|
# 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
@@ -490,7 +490,7 @@ module Spree
|
|
490
490
|
raise CannotRebuildShipments.new(I18n.t('spree.cannot_rebuild_shipments_shipments_not_pending'))
|
491
491
|
else
|
492
492
|
shipments.destroy_all
|
493
|
-
|
493
|
+
shipments.push(*Spree::Config.stock.coordinator_class.new(self).shipments)
|
494
494
|
end
|
495
495
|
end
|
496
496
|
|
@@ -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) }
|
@@ -254,10 +254,9 @@ module Spree
|
|
254
254
|
}).where.not(id: id).first
|
255
255
|
|
256
256
|
if other_return_item && (new_record? || COMPLETED_RECEPTION_STATUSES.include?(reception_status.to_sym))
|
257
|
-
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
257
|
+
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
258
258
|
inventory_unit_id: inventory_unit_id,
|
259
|
-
return_item_id: other_return_item.id
|
260
|
-
})
|
259
|
+
return_item_id: other_return_item.id)
|
261
260
|
end
|
262
261
|
end
|
263
262
|
|
@@ -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?,
|
@@ -182,7 +182,7 @@ module Solidus
|
|
182
182
|
end
|
183
183
|
|
184
184
|
bundle_cleanly{ run "bundle install" } if @plugins_to_be_installed.any?
|
185
|
-
run "spring stop"
|
185
|
+
run "spring stop" if defined?(Spring)
|
186
186
|
|
187
187
|
@plugin_generators_to_run.each do |plugin_generator_name|
|
188
188
|
generate "#{plugin_generator_name} --skip_migrations=true"
|
@@ -445,6 +445,14 @@ module Spree
|
|
445
445
|
# Enumerable of images adhering to the present_image_class interface
|
446
446
|
class_name_attribute :image_attachment_module, default: 'Spree::Image::ActiveStorageAttachment'
|
447
447
|
|
448
|
+
# @!attribute [rw] allowed_image_mime_types
|
449
|
+
#
|
450
|
+
# Defines which MIME types are allowed for images
|
451
|
+
# `%w(image/jpeg image/jpg image/png image/gif).freeze` is the default.
|
452
|
+
#
|
453
|
+
# @return [Array]
|
454
|
+
class_name_attribute :allowed_image_mime_types, default: %w(image/jpeg image/jpg image/png image/gif).freeze
|
455
|
+
|
448
456
|
# Allows switching attachment library for Taxon
|
449
457
|
#
|
450
458
|
# `Spree::Taxon::ActiveStorageAttachment`
|
data/lib/spree/core/engine.rb
CHANGED
@@ -68,6 +68,14 @@ module Spree
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
71
|
+
|
72
|
+
config.after_initialize do
|
73
|
+
if defined?(Spree::Auth::Engine) &&
|
74
|
+
Gem::Version.new(Spree::Auth::VERSION) < Gem::Version.new('2.5.4') &&
|
75
|
+
defined?(Spree::UsersController)
|
76
|
+
Spree::UsersController.protect_from_forgery with: :exception
|
77
|
+
end
|
78
|
+
end
|
71
79
|
end
|
72
80
|
end
|
73
81
|
end
|
@@ -16,7 +16,7 @@ module Spree
|
|
16
16
|
|
17
17
|
def validate_each(record, attribute, value)
|
18
18
|
unless EMAIL_REGEXP.match? value
|
19
|
-
record.errors.add(attribute, :invalid, { value: value }.merge!(options))
|
19
|
+
record.errors.add(attribute, :invalid, **{ value: value }.merge!(options))
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/deprecation.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'active_support/deprecation'
|
4
4
|
|
5
5
|
module Spree
|
6
|
-
Deprecation = ActiveSupport::Deprecation.new('
|
6
|
+
Deprecation = ActiveSupport::Deprecation.new('4.0', 'Solidus')
|
7
7
|
|
8
8
|
# This DeprecatedInstanceVariableProxy transforms instance variable to
|
9
9
|
# deprecated instance variable.
|
@@ -51,7 +51,13 @@ module Spree
|
|
51
51
|
:month, :year, :expiry, :first_name, :last_name, :name
|
52
52
|
]
|
53
53
|
|
54
|
-
@@customer_return_attributes = [
|
54
|
+
@@customer_return_attributes = [
|
55
|
+
:stock_location_id, return_items_attributes: [
|
56
|
+
:id, :inventory_unit_id, :return_authorization_id, :returned, :amount,
|
57
|
+
:reception_status_event, :acceptance_status, :exchange_variant_id,
|
58
|
+
:resellable, :return_reason_id
|
59
|
+
]
|
60
|
+
]
|
55
61
|
|
56
62
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
57
63
|
|
@@ -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
|
@@ -25,7 +25,7 @@ module Spree
|
|
25
25
|
factory_bot_paths: "Spree::TestingSupport::FactoryBot.definition_file_paths",
|
26
26
|
check_factory_bot_version: "Spree::TestingSupport::FactoryBot.check_version",
|
27
27
|
load_all_factories: "Spree::TestingSupport::FactoryBot.add_paths_and_load!",
|
28
|
-
deprecator: Spree::
|
28
|
+
deprecator: Spree::Deprecation
|
29
29
|
)
|
30
30
|
end
|
31
31
|
end
|
data/lib/tasks/upgrade.rake
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
namespace :solidus do
|
4
4
|
namespace :upgrade do
|
5
|
-
|
6
|
-
|
7
|
-
'
|
8
|
-
'solidus:migrations:migrate_address_names:up'
|
5
|
+
task three_point_zero: [
|
6
|
+
'railties:install:migrations',
|
7
|
+
'db:migrate'
|
9
8
|
] do
|
10
|
-
puts "Your Solidus install is ready for Solidus
|
9
|
+
puts "Your Solidus install is ready for Solidus 3.0"
|
11
10
|
end
|
12
11
|
end
|
12
|
+
|
13
|
+
desc "Upgrade to the current Solidus version"
|
14
|
+
task upgrade: 'upgrade:three_point_zero'
|
13
15
|
end
|
data/solidus_core.gemspec
CHANGED
@@ -42,4 +42,24 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_dependency 'kt-paperclip', '~> 6.3'
|
43
43
|
s.add_dependency 'ransack', '~> 2.0'
|
44
44
|
s.add_dependency 'state_machines-activerecord', '~> 0.6'
|
45
|
+
|
46
|
+
s.post_install_message = <<-MSG
|
47
|
+
-------------------------------------------------------------
|
48
|
+
Thank you for using Solidus
|
49
|
+
-------------------------------------------------------------
|
50
|
+
If this is a fresh install, don't forget to run the Solidus
|
51
|
+
installer with the following command:
|
52
|
+
|
53
|
+
$ bin/rails g solidus:install
|
54
|
+
|
55
|
+
If you are updating Solidus from an older version, please run
|
56
|
+
the following commands to complete the update:
|
57
|
+
|
58
|
+
$ bin/rails solidus:upgrade
|
59
|
+
|
60
|
+
Please report any issues at:
|
61
|
+
- https://github.com/solidusio/solidus/issues
|
62
|
+
- http://slack.solidus.io/
|
63
|
+
-------------------------------------------------------------
|
64
|
+
MSG
|
45
65
|
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: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -801,6 +801,7 @@ files:
|
|
801
801
|
- lib/spree/permission_sets/user_management.rb
|
802
802
|
- lib/spree/permitted_attributes.rb
|
803
803
|
- lib/spree/preferences/configuration.rb
|
804
|
+
- lib/spree/preferences/persistable.rb
|
804
805
|
- lib/spree/preferences/preferable.rb
|
805
806
|
- lib/spree/preferences/preferable_class_methods.rb
|
806
807
|
- lib/spree/preferences/scoped_store.rb
|
@@ -888,6 +889,7 @@ files:
|
|
888
889
|
- lib/spree/testing_support/factories/zone_factory.rb
|
889
890
|
- lib/spree/testing_support/factory_bot.rb
|
890
891
|
- lib/spree/testing_support/fixtures/blank.jpg
|
892
|
+
- lib/spree/testing_support/fixtures/file.txt
|
891
893
|
- lib/spree/testing_support/flash.rb
|
892
894
|
- lib/spree/testing_support/job_helpers.rb
|
893
895
|
- lib/spree/testing_support/order_walkthrough.rb
|
@@ -901,8 +903,6 @@ files:
|
|
901
903
|
- lib/spree/testing_support/url_helpers.rb
|
902
904
|
- lib/spree/user_class_handle.rb
|
903
905
|
- lib/spree_core.rb
|
904
|
-
- lib/tasks/migrations/migrate_address_names.rake
|
905
|
-
- lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake
|
906
906
|
- lib/tasks/upgrade.rake
|
907
907
|
- solidus_core.gemspec
|
908
908
|
- vendor/assets/javascripts/jquery.payment.js
|
@@ -912,7 +912,24 @@ homepage: http://solidus.io
|
|
912
912
|
licenses:
|
913
913
|
- BSD-3-Clause
|
914
914
|
metadata: {}
|
915
|
-
post_install_message:
|
915
|
+
post_install_message: |
|
916
|
+
-------------------------------------------------------------
|
917
|
+
Thank you for using Solidus
|
918
|
+
-------------------------------------------------------------
|
919
|
+
If this is a fresh install, don't forget to run the Solidus
|
920
|
+
installer with the following command:
|
921
|
+
|
922
|
+
$ bin/rails g solidus:install
|
923
|
+
|
924
|
+
If you are updating Solidus from an older version, please run
|
925
|
+
the following commands to complete the update:
|
926
|
+
|
927
|
+
$ bin/rails solidus:upgrade
|
928
|
+
|
929
|
+
Please report any issues at:
|
930
|
+
- https://github.com/solidusio/solidus/issues
|
931
|
+
- http://slack.solidus.io/
|
932
|
+
-------------------------------------------------------------
|
916
933
|
rdoc_options: []
|
917
934
|
require_paths:
|
918
935
|
- lib
|
@@ -927,8 +944,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
927
944
|
- !ruby/object:Gem::Version
|
928
945
|
version: 1.8.23
|
929
946
|
requirements: []
|
930
|
-
rubygems_version: 3.1.
|
931
|
-
signing_key:
|
947
|
+
rubygems_version: 3.1.2
|
948
|
+
signing_key:
|
932
949
|
specification_version: 4
|
933
950
|
summary: Essential models, mailers, and classes for the Solidus e-commerce project.
|
934
951
|
test_files: []
|
@@ -1,158 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
|
5
|
-
namespace :solidus do
|
6
|
-
namespace :migrations do
|
7
|
-
namespace :migrate_address_names do
|
8
|
-
desc 'Backfills Spree::Address name attribute using firstname and lastname
|
9
|
-
concatenation in order to retain historical data when upgrading to new
|
10
|
-
address name format'
|
11
|
-
task up: :environment do
|
12
|
-
puts "Combining addresses' firstname and lastname into name ... "
|
13
|
-
class Spree::AddressForMigration < ApplicationRecord
|
14
|
-
self.table_name = 'spree_addresses'
|
15
|
-
end
|
16
|
-
|
17
|
-
records = Spree::AddressForMigration.unscoped.where(name: [nil, ''])
|
18
|
-
count = records.count
|
19
|
-
connection = ActiveRecord::Base.connection
|
20
|
-
adapter_name = connection.adapter_name.downcase
|
21
|
-
shell = Thor::Shell::Basic.new
|
22
|
-
puts " Your DB contains #{count} addresses that may be affected by this task."
|
23
|
-
# `trim` is not needed for pg or mysql when using `concat_ws`:
|
24
|
-
# select concat_ws('joinstring', 'foo', null);
|
25
|
-
# concat_ws
|
26
|
-
# -----------
|
27
|
-
# foo
|
28
|
-
# (1 row)
|
29
|
-
# select concat_ws('joinstring', 'foo', null) = trim(concat_ws('joinstring', 'foo', null));
|
30
|
-
# ?column?
|
31
|
-
# ----------
|
32
|
-
# t
|
33
|
-
# (1 row)
|
34
|
-
unless count.zero?
|
35
|
-
concat_statement = begin
|
36
|
-
case adapter_name
|
37
|
-
when /sqlite/
|
38
|
-
"name = TRIM(COALESCE(firstname, '') || ' ' || COALESCE(lastname, ''))"
|
39
|
-
when /postgres/, /mysql2/
|
40
|
-
"name = CONCAT_WS(' ', firstname, lastname)"
|
41
|
-
else
|
42
|
-
abort " No migration path available for adapter #{adapter_name}. Please write your own."
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# The batch size should be limited to avoid locking the table records for too long. These are
|
47
|
-
# the numbers I got with 1_000_000 records in `spree_addresses`, all with different name and
|
48
|
-
# surname, with postgresql:
|
49
|
-
#
|
50
|
-
# Updating 1000000 records in one shot
|
51
|
-
# batch took 178 seconds
|
52
|
-
#
|
53
|
-
# Updating 1000000 addresses in batches of 200000
|
54
|
-
# batch took 36 seconds
|
55
|
-
# batch took 31 seconds
|
56
|
-
# batch took 31 seconds
|
57
|
-
# batch took 31 seconds
|
58
|
-
# batch took 30 seconds
|
59
|
-
#
|
60
|
-
# Updating 1000000 addresses in batches of 150000
|
61
|
-
# batch took 29 seconds
|
62
|
-
# batch took 27 seconds
|
63
|
-
# batch took 27 seconds
|
64
|
-
# batch took 27 seconds
|
65
|
-
# batch took 26 seconds
|
66
|
-
# batch took 26 seconds
|
67
|
-
# batch took 19 seconds
|
68
|
-
#
|
69
|
-
# Updating 1000000 addresses in batches of 100000
|
70
|
-
# batch took 17 seconds
|
71
|
-
# batch took 15 seconds
|
72
|
-
# batch took 17 seconds
|
73
|
-
# batch took 17 seconds
|
74
|
-
# batch took 17 seconds
|
75
|
-
# batch took 17 seconds
|
76
|
-
# batch took 17 seconds
|
77
|
-
# batch took 17 seconds
|
78
|
-
# batch took 17 seconds
|
79
|
-
# batch took 17 seconds
|
80
|
-
#
|
81
|
-
# This is with mysql:
|
82
|
-
# Updating 1000000 records in one shot
|
83
|
-
# batch updated in 153 seconds
|
84
|
-
#
|
85
|
-
# Updating 1000000 records in batches of 200000, this may take a while...
|
86
|
-
# batch took 41 seconds
|
87
|
-
# batch took 37 seconds
|
88
|
-
# batch took 35 seconds
|
89
|
-
# batch took 28 seconds
|
90
|
-
# batch took 27 seconds
|
91
|
-
#
|
92
|
-
# Updating 1000000 records in batches of 150000, this may take a while...
|
93
|
-
# batch took 30 seconds
|
94
|
-
# batch took 29 seconds
|
95
|
-
# batch took 18 seconds
|
96
|
-
# batch took 18 seconds
|
97
|
-
# batch took 17 seconds
|
98
|
-
# batch took 29 seconds
|
99
|
-
# batch took 12 seconds
|
100
|
-
#
|
101
|
-
# Updating 1000000 records in batches of 100000, this may take a while...
|
102
|
-
# batch took 10 seconds
|
103
|
-
# batch took 11 seconds
|
104
|
-
# batch took 12 seconds
|
105
|
-
# batch took 13 seconds
|
106
|
-
# batch took 12 seconds
|
107
|
-
# batch took 12 seconds
|
108
|
-
# batch took 14 seconds
|
109
|
-
# batch took 19 seconds
|
110
|
-
# batch took 20 seconds
|
111
|
-
# batch took 21 seconds
|
112
|
-
#
|
113
|
-
# Please note that the migration will be much faster when there's no index
|
114
|
-
# on the `name` column. For example, with mysql each batch takes exactly
|
115
|
-
# the same time:
|
116
|
-
#
|
117
|
-
# Updating 1000000 records in batches of 200000, this may take a while...
|
118
|
-
# batch took 17 seconds
|
119
|
-
# batch took 17 seconds
|
120
|
-
# batch took 17 seconds
|
121
|
-
# batch took 16 seconds
|
122
|
-
# batch took 17 seconds
|
123
|
-
#
|
124
|
-
# So, if special need arise, one can drop the index added with migration
|
125
|
-
# 20210122110141_add_name_to_spree_addresses.rb and add the index later,
|
126
|
-
# in non blocking ways. For postgresql:
|
127
|
-
# add_index(:spree_addresses, :name, algorithm: :concurrently)
|
128
|
-
#
|
129
|
-
# For mysql 5.6:
|
130
|
-
# sql = "ALTER TABLE spree_addresses ADD INDEX index_spree_addresses_on_name (name), ALGORITHM=INPLACE, LOCK=NONE;"
|
131
|
-
# ActiveRecord::Base.connection.execute sql
|
132
|
-
#
|
133
|
-
puts ' Data migration will happen in batches. The default value is 100_000, which should take less than 20 seconds on mysql or postgresql.'
|
134
|
-
size = shell.ask(' Please enter a different batch size, or press return to confirm the default: ')
|
135
|
-
size = (size.presence || 100_000).to_i
|
136
|
-
|
137
|
-
abort " Invalid batch size number #{size}, please run the task again." unless size.positive?
|
138
|
-
|
139
|
-
batches_total = (count / size).ceil
|
140
|
-
puts " We're going to migrate #{count} records in #{batches_total} batches of #{size}."
|
141
|
-
|
142
|
-
answer = shell.ask(' Do you want to proceed?', limited_to: ['Y', 'N'], case_insensitive: true)
|
143
|
-
if answer == 'Y'
|
144
|
-
puts " Updating #{count} records in batches of #{size}, this may take a while..."
|
145
|
-
|
146
|
-
records.in_batches(of: size).each.with_index(1) do |batch, index|
|
147
|
-
now = Time.zone.now
|
148
|
-
batch.update_all(concat_statement)
|
149
|
-
puts " Batch #{index}/#{batches_total} done in #{(Time.zone.now - now).to_i} seconds."
|
150
|
-
end
|
151
|
-
else
|
152
|
-
puts " Database not migrated. Please, make sure to fill address's name field on your own."
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :solidus do
|
4
|
-
namespace :migrations do
|
5
|
-
namespace :migrate_default_billing_addresses_to_address_book do
|
6
|
-
task up: :environment do
|
7
|
-
print "Migrating default billing addresses to address book ... "
|
8
|
-
if Spree::UserAddress.where(default_billing: true).any?
|
9
|
-
Spree::LegacyUser.joins(:bill_address).update_all(bill_address_id: nil) # rubocop:disable Rails/SkipsModelValidations
|
10
|
-
end
|
11
|
-
adapter_type = Spree::Base.connection.adapter_name.downcase.to_sym
|
12
|
-
if adapter_type == :mysql2
|
13
|
-
sql = <<~SQL
|
14
|
-
UPDATE spree_user_addresses
|
15
|
-
JOIN spree_users ON spree_user_addresses.user_id = spree_users.id
|
16
|
-
AND spree_user_addresses.address_id = spree_users.bill_address_id
|
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;
|
26
|
-
SQL
|
27
|
-
end
|
28
|
-
Spree::Base.connection.execute sql
|
29
|
-
puts "Success"
|
30
|
-
end
|
31
|
-
|
32
|
-
task down: :environment do
|
33
|
-
Spree::UserAddress.update_all(default_billing: false) # rubocop:disable Rails/SkipsModelValidations
|
34
|
-
puts "Rolled back default billing address migration to address book"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|