solidus_core 2.10.1 → 2.10.2
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/lib/spree/core/controller_helpers/strong_parameters.rb +21 -7
- data/lib/spree/core/importer/order.rb +2 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/permitted_attributes.rb +75 -6
- data/lib/spree/testing_support/factories/user_factory.rb +4 -1
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +8 -1
- data/spec/lib/spree/permitted_attributes_spec.rb +41 -0
- data/spec/models/spree/ability_spec.rb +1 -1
- data/spec/models/spree/promotion/rules/taxon_spec.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086d861b411b9e1e18910a57fed0d2f18f375657d409a7b1135af8a33318ba67'
|
4
|
+
data.tar.gz: 73a855a124bdd7e7a4fa433d7b214746cf5dca67de4a172d5b0c3c399d63a955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfcdb0ec66a4e56859f14c5c0c544d51c7cc033fce8a6eaf9daf94587d10a412ee602cbc63a488a41ce521e8fd03a7adac6c91c8a379d81ef2dcad19ce913416
|
7
|
+
data.tar.gz: 932832d98cac34c0c9c873f47a70a0b97896f8e467a0f8acc5f21b49d99894b82d2d3e8168b53ae9f2147c2e42e06e585e5dd6ab8698fea096e81ff81990ef1b
|
@@ -31,16 +31,30 @@ module Spree
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def permitted_checkout_attributes
|
34
|
-
permitted_attributes.checkout_attributes
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
permitted_attributes.checkout_attributes
|
35
|
+
end
|
36
|
+
|
37
|
+
def permitted_checkout_address_attributes
|
38
|
+
permitted_attributes.checkout_address_attributes
|
39
|
+
end
|
40
|
+
|
41
|
+
def permitted_checkout_delivery_attributes
|
42
|
+
permitted_attributes.checkout_delivery_attributes
|
43
|
+
end
|
44
|
+
|
45
|
+
def permitted_checkout_payment_attributes
|
46
|
+
permitted_attributes.checkout_payment_attributes
|
47
|
+
end
|
48
|
+
|
49
|
+
def permitted_checkout_confirm_attributes
|
50
|
+
permitted_attributes.checkout_confirm_attributes
|
40
51
|
end
|
41
52
|
|
42
53
|
def permitted_order_attributes
|
43
|
-
|
54
|
+
permitted_checkout_address_attributes +
|
55
|
+
permitted_checkout_delivery_attributes +
|
56
|
+
permitted_checkout_payment_attributes +
|
57
|
+
permitted_checkout_confirm_attributes + [
|
44
58
|
line_items_attributes: permitted_line_item_attributes
|
45
59
|
]
|
46
60
|
end
|
@@ -133,7 +133,8 @@ module Spree
|
|
133
133
|
# spree_wombat serializes payment state as status so imported orders should fall back to status field.
|
134
134
|
payment.state = target[:state] || target[:status] || 'completed'
|
135
135
|
payment.payment_method = Spree::PaymentMethod.find_by!(name: target[:payment_method])
|
136
|
-
|
136
|
+
source_attributes = target[:source] || target[:source_attributes]
|
137
|
+
payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
|
137
138
|
payment.save!
|
138
139
|
end
|
139
140
|
end
|
data/lib/spree/core/version.rb
CHANGED
@@ -8,7 +8,10 @@ module Spree
|
|
8
8
|
ATTRIBUTES = [
|
9
9
|
:address_attributes,
|
10
10
|
:address_book_attributes,
|
11
|
-
:
|
11
|
+
:checkout_address_attributes,
|
12
|
+
:checkout_delivery_attributes,
|
13
|
+
:checkout_payment_attributes,
|
14
|
+
:checkout_confirm_attributes,
|
12
15
|
:credit_card_update_attributes,
|
13
16
|
:customer_return_attributes,
|
14
17
|
:image_attributes,
|
@@ -45,10 +48,6 @@ module Spree
|
|
45
48
|
|
46
49
|
@@address_book_attributes = address_attributes + [:default]
|
47
50
|
|
48
|
-
@@checkout_attributes = [
|
49
|
-
:coupon_code, :email, :special_instructions, :use_billing
|
50
|
-
]
|
51
|
-
|
52
51
|
@@credit_card_update_attributes = [
|
53
52
|
:month, :year, :expiry, :first_name, :last_name, :name
|
54
53
|
]
|
@@ -91,7 +90,7 @@ module Spree
|
|
91
90
|
:number, :month, :year, :expiry, :verification_value,
|
92
91
|
:first_name, :last_name, :cc_type, :gateway_customer_profile_id,
|
93
92
|
:gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
|
94
|
-
:existing_card_id, :wallet_payment_source_id
|
93
|
+
:existing_card_id, :wallet_payment_source_id, address_attributes: address_attributes
|
95
94
|
]
|
96
95
|
|
97
96
|
@@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
|
@@ -129,5 +128,75 @@ module Spree
|
|
129
128
|
:product_id, :product, :option_values_attributes, :price,
|
130
129
|
:weight, :height, :width, :depth, :sku, :cost_currency, option_value_ids: [], options: [:name, :value]
|
131
130
|
]
|
131
|
+
|
132
|
+
@@checkout_address_attributes = [
|
133
|
+
:use_billing,
|
134
|
+
:email,
|
135
|
+
bill_address_attributes: address_attributes,
|
136
|
+
ship_address_attributes: address_attributes
|
137
|
+
]
|
138
|
+
|
139
|
+
@@checkout_delivery_attributes = [
|
140
|
+
:special_instructions,
|
141
|
+
shipments_attributes: shipment_attributes
|
142
|
+
]
|
143
|
+
|
144
|
+
@@checkout_payment_attributes = [
|
145
|
+
:coupon_code,
|
146
|
+
payments_attributes: payment_attributes + [
|
147
|
+
source_attributes: source_attributes
|
148
|
+
]
|
149
|
+
]
|
150
|
+
|
151
|
+
@@checkout_confirm_attributes = []
|
152
|
+
|
153
|
+
def self.checkout_attributes
|
154
|
+
Spree::Deprecation.warn <<-WARN.squish, caller
|
155
|
+
checkout_attributes is deprecated, please use the permitted
|
156
|
+
attributes set for the specific step that needs to be updated.
|
157
|
+
|
158
|
+
E.g. permitted_checkout_address_attributes
|
159
|
+
WARN
|
160
|
+
|
161
|
+
CheckoutAdditionalAttributes.new(
|
162
|
+
checkout_address_attributes +
|
163
|
+
checkout_delivery_attributes +
|
164
|
+
checkout_payment_attributes +
|
165
|
+
checkout_confirm_attributes
|
166
|
+
)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class CheckoutAdditionalAttributes < Array
|
171
|
+
def <<(*attributes)
|
172
|
+
super
|
173
|
+
|
174
|
+
inject_attributes_to_all_steps(attributes, :<<)
|
175
|
+
end
|
176
|
+
|
177
|
+
def push(*attributes)
|
178
|
+
super
|
179
|
+
|
180
|
+
inject_attributes_to_all_steps(attributes, :push)
|
181
|
+
end
|
182
|
+
alias append push
|
183
|
+
|
184
|
+
def prepend(*attributes)
|
185
|
+
super
|
186
|
+
|
187
|
+
inject_attributes_to_all_steps(attributes, :prepend)
|
188
|
+
end
|
189
|
+
alias unshift prepend
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
def inject_attributes_to_all_steps(attributes, method)
|
194
|
+
attributes.each do |attribute|
|
195
|
+
PermittedAttributes.checkout_address_attributes.send(method, attribute)
|
196
|
+
PermittedAttributes.checkout_delivery_attributes.send(method, attribute)
|
197
|
+
PermittedAttributes.checkout_payment_attributes.send(method, attribute)
|
198
|
+
PermittedAttributes.checkout_confirm_attributes.send(method, attribute)
|
199
|
+
end
|
200
|
+
end
|
132
201
|
end
|
133
202
|
end
|
@@ -17,7 +17,10 @@ FactoryBot.define do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
factory :admin_user do
|
20
|
-
|
20
|
+
after(:create) do |user, _|
|
21
|
+
admin_role = Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')
|
22
|
+
user.spree_roles << admin_role
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
factory :user_with_addresses do |_u|
|
@@ -23,7 +23,14 @@ RSpec.describe Spree::Core::ControllerHelpers::StrongParameters, type: :controll
|
|
23
23
|
|
24
24
|
describe '#permitted_checkout_attributes' do
|
25
25
|
it 'returns Array class' do
|
26
|
-
|
26
|
+
Spree::Deprecation.silence do
|
27
|
+
expect(controller.permitted_checkout_attributes.class).to eq Spree::CheckoutAdditionalAttributes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is deprecated' do
|
32
|
+
expect(Spree::Deprecation).to receive(:warn)
|
33
|
+
controller.permitted_checkout_attributes
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
|
5
|
+
RSpec.describe Spree::PermittedAttributes do
|
6
|
+
describe ".checkout_attributes" do
|
7
|
+
subject(:permitted_attributes) { described_class }
|
8
|
+
|
9
|
+
it "when read emits a deprecation warning and return all steps attributes" do
|
10
|
+
expect(Spree::Deprecation).to receive(:warn)
|
11
|
+
all_attributes = permitted_attributes.checkout_attributes
|
12
|
+
|
13
|
+
expect(all_attributes).to include(*permitted_attributes.checkout_address_attributes)
|
14
|
+
expect(all_attributes).to include(*permitted_attributes.checkout_delivery_attributes)
|
15
|
+
expect(all_attributes).to include(*permitted_attributes.checkout_payment_attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "when changed emits a deprecation warning and push changes to all steps' attributes" do
|
19
|
+
expect(Spree::Deprecation).to receive(:warn).exactly(4).times
|
20
|
+
permitted_attributes.checkout_attributes.push :appended_attribute
|
21
|
+
permitted_attributes.checkout_attributes.append :appended_with_alias_attribute
|
22
|
+
permitted_attributes.checkout_attributes << :another_appended_attribute
|
23
|
+
permitted_attributes.checkout_attributes.prepend :prepended_attribute
|
24
|
+
|
25
|
+
checkout_steps_attributes = [
|
26
|
+
permitted_attributes.checkout_address_attributes,
|
27
|
+
permitted_attributes.checkout_delivery_attributes,
|
28
|
+
permitted_attributes.checkout_payment_attributes,
|
29
|
+
permitted_attributes.checkout_confirm_attributes
|
30
|
+
]
|
31
|
+
|
32
|
+
checkout_steps_attributes.each do |step_attributes|
|
33
|
+
expect(step_attributes).to include(
|
34
|
+
:appended_attribute,
|
35
|
+
:appended_with_alias_attribute,
|
36
|
+
:another_appended_attribute,
|
37
|
+
:prepended_attribute)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -59,7 +59,7 @@ RSpec.describe Spree::Ability, type: :model do
|
|
59
59
|
let(:resource) { Object.new }
|
60
60
|
|
61
61
|
context 'with admin user' do
|
62
|
-
let(:user) {
|
62
|
+
let(:user) { create :admin_user }
|
63
63
|
it_should_behave_like 'access granted'
|
64
64
|
it_should_behave_like 'index allowed'
|
65
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: 2.10.
|
4
|
+
version: 2.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -976,6 +976,7 @@ files:
|
|
976
976
|
- spec/lib/spree/migrations_spec.rb
|
977
977
|
- spec/lib/spree/money_spec.rb
|
978
978
|
- spec/lib/spree/permission_sets/default_customer_spec.rb
|
979
|
+
- spec/lib/spree/permitted_attributes_spec.rb
|
979
980
|
- spec/lib/spree/promo/environment_spec.rb
|
980
981
|
- spec/lib/tasks/dummy_task.rake
|
981
982
|
- spec/lib/tasks/dummy_task_spec.rb
|