solidus_core 2.8.1 → 2.8.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6a0e506dd5c20cd114029a4d8f7cf6c9dff0ef0ce08c3b92cdd24e39b58f97e
4
- data.tar.gz: 1936cc0f6fda95d9a4931b584eeec1c3529d64dec7aee80c92e0b58183d0c19b
3
+ metadata.gz: 12240271e722fffd557b6ef159c53f8df695472c383200d6869b2634643fd91b
4
+ data.tar.gz: 54fa7b31fdc8688eae2146814cb53b0fe95a44e0769dd4c4f601384662458644
5
5
  SHA512:
6
- metadata.gz: fd93440711741bf2970e57db6cc86325f0ae2faa28642651a959f40004bf9b384cd39343d23836ef6bdb5565c04aa818822b1443284c3feee93ebdc51b4b4b84
7
- data.tar.gz: 46461444d4462294444911f9ec1a7da35e75e82a3713e62879ef7e08cc4f58cc02b01eefd2678cee624cd3158ad165a28c0ecefb9c456cf1df5167af1b812550
6
+ metadata.gz: a42f2ce13d73407b08ee0fa5dc1d86bd3a857cded64d78205e898a3786480239dec54a160de606b35c99e59361792670cef7a241843747b8633a3695511428a2
7
+ data.tar.gz: 3a45c91be1329e0f93e6291f8a74d381e477689ecbf2d492d6ccaff7346326bb542197faa04ca8d8b5940bd29df8c7da1a91d902733b9e55fae50177608404e5
@@ -7,12 +7,12 @@ module Spree
7
7
  # to show the most popular products for a particular taxon (that is an exercise left to the developer.)
8
8
  def taxon_preview(taxon, max = 4)
9
9
  price_scope = Spree::Price.where(current_pricing_options.search_arguments)
10
- products = taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT (spree_products.id), spree_products.*, spree_products_taxons.position").limit(max)
10
+ products = taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT spree_products.*, spree_products_taxons.position").limit(max)
11
11
  if products.size < max
12
12
  products_arel = Spree::Product.arel_table
13
13
  taxon.descendants.each do |descendent_taxon|
14
14
  to_get = max - products.length
15
- products += descendent_taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT (spree_products.id), spree_products.*, spree_products_taxons.position").where(products_arel[:id].not_in(products.map(&:id))).limit(to_get)
15
+ products += descendent_taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT spree_products.*, spree_products_taxons.position").where(products_arel[:id].not_in(products.map(&:id))).limit(to_get)
16
16
  break if products.size >= max
17
17
  end
18
18
  end
@@ -63,9 +63,10 @@ module Spree
63
63
  #
64
64
  # SELECT COUNT(*) ...
65
65
  add_search_scope :in_taxon do |taxon|
66
- includes(:classifications).
67
- where("spree_products_taxons.taxon_id" => taxon.self_and_descendants.pluck(:id)).
68
- order(Spree::Classification.arel_table[:position].asc)
66
+ includes(:classifications)
67
+ .where('spree_products_taxons.taxon_id' => taxon.self_and_descendants.pluck(:id))
68
+ .select(Spree::Classification.arel_table[:position])
69
+ .order(Spree::Classification.arel_table[:position].asc)
69
70
  end
70
71
 
71
72
  # This scope selects products in all taxons AND all its descendants
@@ -39,7 +39,7 @@ class Spree::StoreCredit < Spree::PaymentSource
39
39
  before_validation :associate_credit_type
40
40
  before_validation :validate_category_unchanged, on: :update
41
41
  before_destroy :validate_no_amount_used
42
- validate :validate_no_amount_used, if: :discarded?
42
+ before_discard :validate_no_amount_used
43
43
 
44
44
  attr_accessor :action, :action_amount, :action_originator, :action_authorization_code, :store_credit_reason
45
45
 
@@ -268,6 +268,7 @@ class Spree::StoreCredit < Spree::PaymentSource
268
268
  def validate_no_amount_used
269
269
  if amount_used > 0
270
270
  errors.add(:amount_used, 'is greater than zero. Can not delete store credit')
271
+ throw :abort
271
272
  end
272
273
  end
273
274
 
@@ -21,15 +21,28 @@ class CreateSpreeStoreCreditReasonsTable < ActiveRecord::Migration[5.1]
21
21
  StoreCreditReason.create!(name: update_reason.name)
22
22
  end
23
23
 
24
- drop_table :spree_store_credit_update_reasons
25
- rename_column :spree_store_credit_events, :update_reason_id, :store_credit_reason_id
24
+ add_column :spree_store_credit_events, :store_credit_reason_id, :integer
25
+ execute "update spree_store_credit_events set store_credit_reason_id = update_reason_id"
26
+
27
+ # TODO: table spree_store_credit_update_reasons and column
28
+ # column spree_store_credit_update_reasons.update_reason_id
29
+ # must be dropped in a future Solidus release
26
30
  end
27
31
 
28
32
  def down
29
- create_table :spree_store_credit_update_reasons do |t|
30
- t.string :name
31
-
32
- t.timestamps
33
+ # This table and column may not exist anymore as another irreversible
34
+ # migration may have removed it later. They must be added back or the
35
+ # `up` method would fail
36
+ unless table_exists? :spree_store_credit_update_reasons
37
+ create_table :spree_store_credit_update_reasons do |t|
38
+ t.string :name
39
+
40
+ t.timestamps
41
+ end
42
+
43
+ unless column_exists? :spree_store_credit_events, :update_reason_id
44
+ add_column :spree_store_credit_events, :update_reason_id, :integer
45
+ end
33
46
  end
34
47
 
35
48
  StoreCreditReason.all.each do |store_credit_reason|
@@ -37,6 +50,6 @@ class CreateSpreeStoreCreditReasonsTable < ActiveRecord::Migration[5.1]
37
50
  end
38
51
 
39
52
  drop_table :spree_store_credit_reasons
40
- rename_column :spree_store_credit_events, :store_credit_reason_id, :update_reason_id
53
+ remove_column :spree_store_credit_events, :store_credit_reason_id
41
54
  end
42
55
  end
@@ -5,10 +5,11 @@ require 'solidus/migrations/promotions_with_code_handlers'
5
5
  class RemoveCodeFromSpreePromotions < ActiveRecord::Migration[5.1]
6
6
  class Promotion < ActiveRecord::Base
7
7
  self.table_name = "spree_promotions"
8
+ self.ignored_columns = %w(type)
8
9
  end
9
10
 
10
11
  def up
11
- promotions_with_code = Promotion.where.not(code: nil)
12
+ promotions_with_code = Promotion.where.not(code: [nil, ''])
12
13
 
13
14
  if promotions_with_code.any?
14
15
  # You have some promotions with "code" field present! This is not good
@@ -58,6 +58,9 @@ module Spree
58
58
 
59
59
  def setup_assets
60
60
  @lib_name = 'spree'
61
+
62
+ empty_directory 'app/assets/images'
63
+
61
64
  %w{javascripts stylesheets images}.each do |path|
62
65
  empty_directory "vendor/assets/#{path}/spree/frontend" if defined? Spree::Frontend || Rails.env.test?
63
66
  empty_directory "vendor/assets/#{path}/spree/backend" if defined? Spree::Backend || Rails.env.test?
@@ -31,16 +31,30 @@ module Spree
31
31
  end
32
32
 
33
33
  def permitted_checkout_attributes
34
- permitted_attributes.checkout_attributes + [
35
- bill_address_attributes: permitted_address_attributes,
36
- ship_address_attributes: permitted_address_attributes,
37
- payments_attributes: permitted_payment_attributes,
38
- shipments_attributes: permitted_shipment_attributes
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
- permitted_checkout_attributes + [
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,9 @@ module Spree
133
133
  # spree_wombat serializes payment state as status so imported orders should fall back to status field.
134
134
  payment.state = p[:state] || p[:status] || 'completed'
135
135
  payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
136
- payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
136
+ source_attributes = p[:source] || p[:source_attributes]
137
+ payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
138
+
137
139
  payment.save!
138
140
  end
139
141
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  def self.solidus_version
5
- "2.8.1"
5
+ "2.8.6"
6
6
  end
7
7
 
8
8
  def self.solidus_gem_version
@@ -8,7 +8,10 @@ module Spree
8
8
  ATTRIBUTES = [
9
9
  :address_attributes,
10
10
  :address_book_attributes,
11
- :checkout_attributes,
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
@@ -93,7 +93,9 @@ module Spree
93
93
  def select_select2_result(value)
94
94
  # results are in a div appended to the end of the document
95
95
  within_entire_page do
96
- page.find("div.select2-result-label", text: /#{Regexp.escape(value)}/i, match: :prefer_exact).click
96
+ expect(page).to have_selector('.select2-result-label', visible: true)
97
+ find("div.select2-result-label", text: /#{Regexp.escape(value)}/i, match: :prefer_exact).click
98
+ expect(page).not_to have_selector('.select2-result-label')
97
99
  end
98
100
  end
99
101
 
@@ -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
- expect(controller.permitted_checkout_attributes.class).to eq Array
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
@@ -44,7 +44,18 @@ RSpec.describe RemoveCodeFromSpreePromotions do
44
44
  DatabaseCleaner.clean_with(:truncation)
45
45
  end
46
46
 
47
+ let(:promotion_with_code) { create(:promotion) }
48
+
49
+ before do
50
+ # We can't set code via factory since `code=` is currently raising
51
+ # an error, see more at:
52
+ # https://github.com/solidusio/solidus/blob/cf96b03eb9e80002b69736e082fd485c870ab5d9/core/app/models/spree/promotion.rb#L65
53
+ promotion_with_code.update_column(:code, code)
54
+ end
55
+
47
56
  context 'when there are no promotions with code' do
57
+ let(:code) { '' }
58
+
48
59
  it 'does not call any promotion with code handler' do
49
60
  expect(described_class).not_to receive(:promotions_with_code_handler)
50
61
 
@@ -53,14 +64,7 @@ RSpec.describe RemoveCodeFromSpreePromotions do
53
64
  end
54
65
 
55
66
  context 'when there are promotions with code' do
56
- let(:promotion_with_code) { create(:promotion) }
57
-
58
- before do
59
- # We can't set code via factory since `code=` is currently raising
60
- # an error, see more at:
61
- # https://github.com/solidusio/solidus/blob/cf96b03eb9e80002b69736e082fd485c870ab5d9/core/app/models/spree/promotion.rb#L65
62
- promotion_with_code.update_column(:code, 'Just An Old Promo Code')
63
- end
67
+ let(:code) { 'Just An Old Promo Code' }
64
68
 
65
69
  context 'with the deafult handler (Solidus::Migrations::PromotionWithCodeHandlers::RaiseException)' do
66
70
  it 'raise a StandardError exception' do
@@ -96,6 +100,14 @@ RSpec.describe RemoveCodeFromSpreePromotions do
96
100
  end
97
101
  end
98
102
 
103
+ context 'with promotions with type set (legacy feature)' do
104
+ let(:promotion_with_code) { create(:promotion, type: 'Spree::Promotion') }
105
+
106
+ it 'does not raise a STI error' do
107
+ expect { subject }.not_to raise_error
108
+ end
109
+ end
110
+
99
111
  context 'when there is a Spree::PromotionCode with the same value' do
100
112
  context 'associated with the same promotion' do
101
113
  let!(:existing_promotion_code) { create(:promotion_code, value: 'just an old promo code', promotion: promotion_with_code) }
@@ -91,6 +91,7 @@ RSpec.describe Spree::Promotion::Rules::Taxon, type: :model do
91
91
  before do
92
92
  taxon.children << taxon2
93
93
  taxon.save!
94
+ taxon.reload
94
95
  product.taxons = [taxon2, taxon3]
95
96
  rule.taxons = [taxon, taxon3]
96
97
  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.8.1
4
+ version: 2.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-13 00:00:00.000000000 Z
11
+ date: 2020-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -956,6 +956,7 @@ files:
956
956
  - spec/lib/spree/migrations_spec.rb
957
957
  - spec/lib/spree/money_spec.rb
958
958
  - spec/lib/spree/permission_sets/default_customer_spec.rb
959
+ - spec/lib/spree/permitted_attributes_spec.rb
959
960
  - spec/lib/tasks/dummy_task.rake
960
961
  - spec/lib/tasks/dummy_task_spec.rb
961
962
  - spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb
@@ -1214,8 +1215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1214
1215
  - !ruby/object:Gem::Version
1215
1216
  version: 1.8.23
1216
1217
  requirements: []
1217
- rubyforge_project:
1218
- rubygems_version: 2.7.3
1218
+ rubygems_version: 3.0.3
1219
1219
  signing_key:
1220
1220
  specification_version: 4
1221
1221
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.