solidus_core 2.11.4 → 2.11.9
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.
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.rb +2 -0
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -11
- data/app/models/spree/address.rb +28 -5
- data/app/models/spree/base.rb +39 -13
- 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_merger.rb +1 -1
- data/app/models/spree/payment.rb +10 -3
- data/app/models/spree/payment_method.rb +3 -0
- 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/product.rb +8 -2
- 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/shipping_method.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +2 -2
- data/app/models/spree/stock/inventory_validator.rb +2 -2
- data/app/models/spree/taxon/active_storage_attachment.rb +1 -2
- data/app/models/spree/taxon/paperclip_attachment.rb +1 -0
- data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
- data/lib/generators/solidus/install/install_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +3 -0
- data/lib/spree/app_configuration.rb +8 -0
- data/lib/spree/core.rb +0 -4
- data/lib/spree/core/engine.rb +6 -7
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/preferences/persistable.rb +23 -0
- data/lib/spree/testing_support.rb +19 -28
- data/lib/spree/testing_support/dummy_app.rb +4 -2
- data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
- data/lib/spree/testing_support/factories.rb +8 -2
- data/lib/spree/testing_support/factories/address_factory.rb +6 -2
- data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -2
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +4 -2
- data/lib/spree/testing_support/factories/calculator_factory.rb +4 -2
- data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
- data/lib/spree/testing_support/factories/country_factory.rb +4 -2
- data/lib/spree/testing_support/factories/credit_card_factory.rb +4 -2
- data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -2
- data/lib/spree/testing_support/factories/image_factory.rb +4 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -2
- data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/option_type_factory.rb +7 -2
- data/lib/spree/testing_support/factories/option_value_factory.rb +4 -2
- data/lib/spree/testing_support/factories/order_factory.rb +11 -2
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/payment_factory.rb +9 -2
- data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -2
- data/lib/spree/testing_support/factories/price_factory.rb +6 -2
- data/lib/spree/testing_support/factories/product_factory.rb +10 -2
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
- data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +4 -2
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
- data/lib/spree/testing_support/factories/property_factory.rb +4 -2
- data/lib/spree/testing_support/factories/refund_factory.rb +7 -2
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +4 -2
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -2
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +4 -2
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -2
- data/lib/spree/testing_support/factories/return_item_factory.rb +8 -2
- data/lib/spree/testing_support/factories/return_reason_factory.rb +4 -2
- data/lib/spree/testing_support/factories/role_factory.rb +4 -2
- data/lib/spree/testing_support/factories/shipment_factory.rb +9 -2
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +4 -2
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -2
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
- data/lib/spree/testing_support/factories/state_factory.rb +7 -2
- data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
- data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -2
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -2
- data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +4 -2
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -2
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +4 -2
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +4 -2
- data/lib/spree/testing_support/factories/store_factory.rb +4 -2
- data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -2
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -2
- data/lib/spree/testing_support/factories/taxon_factory.rb +6 -2
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +4 -2
- data/lib/spree/testing_support/factories/user_factory.rb +8 -2
- data/lib/spree/testing_support/factories/variant_factory.rb +9 -2
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -2
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
- data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
- data/lib/spree/testing_support/factory_bot.rb +68 -0
- data/lib/spree/testing_support/fixtures/file.txt +1 -0
- data/lib/spree/testing_support/order_walkthrough.rb +9 -9
- data/lib/spree/testing_support/sequences.rb +4 -1
- data/lib/tasks/migrations/migrate_address_names.rake +158 -0
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +26 -0
- data/lib/tasks/upgrade.rake +13 -0
- data/solidus_core.gemspec +23 -1
- metadata +32 -6
- data/lib/spree/awesome_nested_set_override.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6be99509f3f7cdd74113426927e8751493ea311563e4d2a4fbf57d5661da05d
|
4
|
+
data.tar.gz: e5124764c6cfadd679394db2f28d1a45171f5cf45caa571f679a567a985ac5b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0093e9c554425147adf6bbeadf7a7f4ed91190b5a34664935103bfae6c0cb277d62bb44c974b8a625235a400cc91cf00736fceeb971229d56d97fa83eb5c3947'
|
7
|
+
data.tar.gz: bb18cd30482e0bcd1a8efaf671fba77279a04f3f1bf0cb06632fb9bc577af67544cbabcb14e5eae3347d71f74946fe86dd5ee60d4c49a0f130abe4153b45995a
|
@@ -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/address.rb
CHANGED
@@ -92,6 +92,12 @@ module Spree
|
|
92
92
|
if base['lastname'].presence || base['last_name'].presence
|
93
93
|
base['lastname'] = name_from_attributes.last_name
|
94
94
|
end
|
95
|
+
|
96
|
+
virtual_name = name_from_attributes.value
|
97
|
+
if base['name'].blank? && virtual_name.present?
|
98
|
+
base['name'] = virtual_name
|
99
|
+
end
|
100
|
+
|
95
101
|
excluded_attributes = DB_ONLY_ATTRS + %w(first_name last_name)
|
96
102
|
|
97
103
|
base.except(*excluded_attributes)
|
@@ -120,7 +126,11 @@ module Spree
|
|
120
126
|
# @return [Boolean] true if the two addresses have the same address fields
|
121
127
|
def ==(other_address)
|
122
128
|
return false unless other_address && other_address.respond_to?(:value_attributes)
|
123
|
-
|
129
|
+
if Spree::Config.use_combined_first_and_last_name_in_address
|
130
|
+
value_attributes.except(*LEGACY_NAME_ATTRS) == other_address.value_attributes.except(*LEGACY_NAME_ATTRS)
|
131
|
+
else
|
132
|
+
value_attributes == other_address.value_attributes
|
133
|
+
end
|
124
134
|
end
|
125
135
|
|
126
136
|
# @deprecated Do not use this. Use Address.== instead.
|
@@ -193,17 +203,30 @@ module Spree
|
|
193
203
|
country && country.iso
|
194
204
|
end
|
195
205
|
|
206
|
+
before_save :set_name_from_firstname_and_lastname
|
207
|
+
|
208
|
+
def set_name_from_firstname_and_lastname
|
209
|
+
name_from_firstname_and_lastname = Spree::Address::Name.from_attributes(attributes.except(:name, 'name'))
|
210
|
+
|
211
|
+
if read_attribute(:name).blank? && name_from_firstname_and_lastname.present?
|
212
|
+
write_attribute(:name, name_from_firstname_and_lastname)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
196
216
|
# @return [String] the full name on this address
|
197
217
|
def name
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
218
|
+
self[:name] || begin
|
219
|
+
Spree::Address::Name.new(
|
220
|
+
read_attribute(:firstname),
|
221
|
+
read_attribute(:lastname)
|
222
|
+
).value
|
223
|
+
end
|
202
224
|
end
|
203
225
|
|
204
226
|
def name=(value)
|
205
227
|
return if value.nil?
|
206
228
|
|
229
|
+
write_attribute(:name, value)
|
207
230
|
name_from_value = Spree::Address::Name.new(value)
|
208
231
|
write_attribute(:firstname, name_from_value.first_name)
|
209
232
|
write_attribute(:lastname, name_from_value.last_name)
|
data/app/models/spree/base.rb
CHANGED
@@ -1,24 +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
|
-
|
10
|
-
|
11
|
-
|
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)
|
12
23
|
end
|
13
24
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
40
|
+
|
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
|
22
48
|
end
|
23
49
|
|
24
50
|
if Kaminari.config.page_method_name != :page
|
@@ -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
|
@@ -128,7 +128,7 @@ module Spree
|
|
128
128
|
# @param [Spree::LineItem] line_item The line item which could not be saved
|
129
129
|
# @return [void]
|
130
130
|
def handle_error(line_item)
|
131
|
-
order.errors
|
131
|
+
order.errors.add(:base, line_item.errors.full_messages)
|
132
132
|
end
|
133
133
|
|
134
134
|
# Save the order totals after merge
|
data/app/models/spree/payment.rb
CHANGED
@@ -168,9 +168,16 @@ module Spree
|
|
168
168
|
|
169
169
|
def validate_source
|
170
170
|
if source && !source.valid?
|
171
|
-
|
172
|
-
|
173
|
-
|
171
|
+
if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
|
172
|
+
source.errors.each do |error|
|
173
|
+
field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{error.attribute}")
|
174
|
+
errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error.message}")
|
175
|
+
end
|
176
|
+
else
|
177
|
+
source.errors.each do |field, error|
|
178
|
+
field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{field}")
|
179
|
+
errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error}")
|
180
|
+
end
|
174
181
|
end
|
175
182
|
end
|
176
183
|
if errors.any?
|
@@ -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
|
|
@@ -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
|
data/app/models/spree/product.rb
CHANGED
@@ -366,8 +366,14 @@ module Spree
|
|
366
366
|
# If the master is invalid, the Product object will be assigned its errors
|
367
367
|
def validate_master
|
368
368
|
unless master.valid?
|
369
|
-
|
370
|
-
errors.
|
369
|
+
if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
|
370
|
+
master.errors.each do |error|
|
371
|
+
errors.add(error.attribute, error.message)
|
372
|
+
end
|
373
|
+
else
|
374
|
+
master.errors.each do |att, error|
|
375
|
+
errors.add(att, error)
|
376
|
+
end
|
371
377
|
end
|
372
378
|
end
|
373
379
|
end
|
@@ -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
|