solidus_core 4.6.2 → 4.6.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54346c8f091dd2395832f0e0118d80c50e52f6fc7bda852c0147164061f28055
4
- data.tar.gz: 445ada16ce8a53ae7f4904fdacae27215954de7f2f1387a39ae4f6b8c8ee73be
3
+ metadata.gz: 9ab7d28a51c8f5ad031bf0613a5dc1c3fddff295f09edf5032ee6b5173d22ca3
4
+ data.tar.gz: 4e5e1b57bb62eeff08f426242c042603eb8112804afaca7490b618739fc4e564
5
5
  SHA512:
6
- metadata.gz: 92d7572979dddd22c078e452a0ade011ac4f230876ea24cbb130917d7c088086d316685e2efe6618d73ed5317a24aa17aeb9376cb6d18c4a4704c56f0f3caf51
7
- data.tar.gz: e815c14e8992cdb3549c44711338c43e24f8dfe2195b6f0540b9427f0f7043832d94e7f78c32028af579ea842a53a8edbb53714d5fa7ee97fda962e12b8b19c6
6
+ metadata.gz: 9a04c4401ce4d6b775b9f0ef450315941cc944722429d8cbc066d8f608ffd567b41d6aa53060ce1fe90a76292676b359c0ca15d6255a59f54cbeaea3dfa02c20
7
+ data.tar.gz: a178b017f4121166d78af2ce80ce2ba9dbbfc04e87c677f30d0bca86874f4c02ee2cd3511b3b2cb5caef70cf2c5ffdbc85ef8a8afa4c721381b3e490eb4458bb
@@ -14,19 +14,19 @@ module Spree
14
14
 
15
15
  def permitted_credit_card_update_attributes
16
16
  permitted_attributes.credit_card_update_attributes + [
17
- address_attributes: permitted_address_attributes
17
+ { address_attributes: permitted_address_attributes }
18
18
  ]
19
19
  end
20
20
 
21
21
  def permitted_payment_attributes
22
22
  permitted_attributes.payment_attributes + [
23
- source_attributes: permitted_source_attributes
23
+ { source_attributes: permitted_source_attributes }
24
24
  ]
25
25
  end
26
26
 
27
27
  def permitted_source_attributes
28
28
  permitted_attributes.source_attributes + [
29
- address_attributes: permitted_address_attributes
29
+ { address_attributes: permitted_address_attributes }
30
30
  ]
31
31
  end
32
32
 
@@ -52,20 +52,22 @@ module Spree
52
52
  permitted_checkout_payment_attributes +
53
53
  permitted_attributes.customer_metadata_attributes +
54
54
  permitted_checkout_confirm_attributes + [
55
- line_items_attributes: permitted_line_item_attributes
55
+ { line_items_attributes: permitted_line_item_attributes }
56
56
  ]
57
57
  end
58
58
 
59
59
  def permitted_product_attributes
60
60
  permitted_attributes.product_attributes + [
61
- product_properties_attributes: permitted_product_properties_attributes
61
+ { product_properties_attributes: permitted_product_properties_attributes }
62
62
  ]
63
63
  end
64
64
 
65
65
  def permitted_user_attributes
66
66
  permitted_attributes.user_attributes + [
67
- bill_address_attributes: permitted_address_attributes,
68
- ship_address_attributes: permitted_address_attributes
67
+ {
68
+ bill_address_attributes: permitted_address_attributes,
69
+ ship_address_attributes: permitted_address_attributes
70
+ }
69
71
  ]
70
72
  end
71
73
  end
@@ -49,7 +49,7 @@ module Spree
49
49
  if Spree::Config[:show_raw_product_description]
50
50
  raw(product.description)
51
51
  else
52
- raw(product.description.gsub(/(.*?)\r?\n\r?\n/m, '<p>\1</p>'))
52
+ sanitize(product.description.gsub(/(.*?)\r?\n\r?\n/m, '<p>\1</p>'))
53
53
  end
54
54
  end
55
55
 
@@ -130,14 +130,14 @@ module Spree
130
130
 
131
131
  # Updates the roles in keeping with the given ability's permissions
132
132
  #
133
- # Roles that are not accessible to the given ability will be ignored. It
134
- # also ensure not to remove non accessible roles when assigning new
135
- # accessible ones.
133
+ # Roles that the given ability cannot manage will be ignored. It also
134
+ # ensure not to remove non manageable roles when assigning new manageable
135
+ # ones.
136
136
  #
137
137
  # @param given_roles [Spree::Role]
138
138
  # @param ability [Spree::Ability]
139
139
  def update_spree_roles(given_roles, ability:)
140
- accessible_roles = Spree::Role.accessible_by(ability)
140
+ accessible_roles = Spree::Role.accessible_by(ability, :manage)
141
141
  non_accessible_roles = Spree::Role.all - accessible_roles
142
142
  new_accessible_roles = given_roles - non_accessible_roles
143
143
  self.spree_roles = spree_roles - accessible_roles + new_accessible_roles
@@ -8,6 +8,10 @@ module Spree
8
8
  # * :payment_method_id Id of payment method used for this payment
9
9
  # * :source_attributes Attributes used to build the source of this payment. Usually a {CreditCard}
10
10
  # * :wallet_payment_source_id (Integer): The id of a {WalletPaymentSource} to use
11
+ # * :gateway_customer_profile_id, :gateway_payment_profile_id (String): Gateway
12
+ # identifiers for a new {CreditCard}, e.g. a one-time token. Raises
13
+ # ActiveRecord::RecordNotFound if either already belongs to a {CreditCard}
14
+ # owned by a different user.
11
15
  # @param request_env [Hash] rack env of user creating the payment
12
16
  # @param payment [Payment] Internal use only. Instead of making a new payment, change the attributes for an existing one.
13
17
  def initialize(order, attributes, payment: nil, request_env: {})
@@ -44,6 +48,7 @@ module Spree
44
48
  def build_source
45
49
  payment_method = payment.payment_method
46
50
  if source_attributes.present? && payment_method.try(:payment_source_class)
51
+ ensure_gateway_profile_ownership!(payment_method.payment_source_class)
47
52
  payment.source = payment_method.payment_source_class.new(source_attributes)
48
53
  payment.source.payment_method_id = payment_method.id
49
54
  if order && payment.source.respond_to?(:user=)
@@ -52,6 +57,24 @@ module Spree
52
57
  end
53
58
  end
54
59
 
60
+ # Gateway profile ids may only be submitted for a new source when they are
61
+ # unknown to the store (e.g. a one-time token) or already belong to the
62
+ # order's user. Raises if either id is stored on a {CreditCard} owned by a
63
+ # different user, so customers cannot pay with another customer's stored
64
+ # gateway credential.
65
+ def ensure_gateway_profile_ownership!(source_class)
66
+ return unless source_class <= Spree::CreditCard
67
+
68
+ %i[gateway_customer_profile_id gateway_payment_profile_id].each do |attribute|
69
+ value = source_attributes[attribute]
70
+ next if value.blank?
71
+
72
+ foreign_cards = Spree::CreditCard.where(attribute => value).where.not(user_id: nil)
73
+ foreign_cards = foreign_cards.where.not(user_id: order.user_id) if order&.user_id
74
+ raise ActiveRecord::RecordNotFound if foreign_cards.exists?
75
+ end
76
+ end
77
+
55
78
  def build_from_wallet_payment_source
56
79
  wallet_payment_source_id = source_attributes.fetch(:wallet_payment_source_id)
57
80
  raise(ActiveRecord::RecordNotFound) if order.user.nil?
@@ -63,18 +63,18 @@ module Spree
63
63
  can :create, ReturnAuthorization do |return_authorization|
64
64
  return_authorization.order.user == user
65
65
  end
66
- can [:read, :update], CreditCard, user_id: user.id
66
+ can [:read, :update], CreditCard, user_id: user.id if user.persisted?
67
67
  can :read, Product
68
68
  can :read, ProductProperty
69
69
  can :read, Property
70
70
  can :create, Spree.user_class
71
- can [:show, :update, :update_email], Spree.user_class, id: user.id
71
+ can [:show, :update, :update_email], Spree.user_class, id: user.id if user.persisted?
72
72
  can :read, State
73
73
  can :read, StockItem, stock_location: { active: true }
74
74
  can :read, StockLocation, active: true
75
75
  can :read, Taxon
76
76
  can :read, Taxonomy
77
- can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id
77
+ can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id if user.persisted?
78
78
  can [:read, :view_out_of_stock], Variant
79
79
  can :read, Zone
80
80
  end
@@ -147,6 +147,11 @@ module Spree
147
147
  super || Spree::TaxCategory.find_by(is_default: true)
148
148
  end
149
149
 
150
+ # @return [Integer] tax category id for this product, or the default tax category id
151
+ def tax_category_id
152
+ super || tax_category&.id
153
+ end
154
+
150
155
  # Ensures option_types and product_option_types exist for keys in
151
156
  # option_values_hash.
152
157
  #
@@ -359,14 +364,17 @@ module Spree
359
364
  run_callbacks(:touch)
360
365
  end
361
366
 
362
- # Iterate through this product's taxons and taxonomies and touch their timestamps in a batch
367
+ # Iterate through this product's taxons and taxonomies and touch their timestamps
363
368
  def touch_taxons
364
- taxons_to_touch = taxons.flat_map(&:self_and_ancestors).uniq
365
- unless taxons_to_touch.empty?
366
- Spree::Taxon.where(id: taxons_to_touch.map(&:id)).update_all(updated_at: Time.current)
369
+ taxons_to_touch = taxons.flat_map(&:self_and_ancestors).uniq.sort_by(&:id)
370
+ return if taxons_to_touch.empty?
371
+
372
+ time = Time.current
373
+ taxons_to_touch.each { |taxon| taxon.update_column(:updated_at, time) }
367
374
 
368
- taxonomy_ids_to_touch = taxons_to_touch.flat_map(&:taxonomy_id).uniq
369
- Spree::Taxonomy.where(id: taxonomy_ids_to_touch).update_all(updated_at: Time.current)
375
+ taxonomy_ids_to_touch = taxons_to_touch.map(&:taxonomy_id).uniq
376
+ Spree::Taxonomy.where(id: taxonomy_ids_to_touch).order(:id).each do |taxonomy|
377
+ taxonomy.touch(time:)
370
378
  end
371
379
  end
372
380
 
@@ -41,6 +41,7 @@ module Spree
41
41
 
42
42
  validate :eligible_exchange_variant
43
43
  validate :belongs_to_same_customer_order
44
+ validate :belongs_to_return_authorization_order, if: -> { inventory_unit_id_changed? || return_authorization_id_changed? }
44
45
  validate :validate_acceptance_status_for_reimbursement
45
46
  validate :validate_no_other_completed_return_items
46
47
 
@@ -177,16 +178,16 @@ module Spree
177
178
  exchange_requested? || sibling_intended_for_exchange('unexchanged')
178
179
  end
179
180
 
181
+ def currency
182
+ return_authorization.try(:currency) || Spree::Config[:currency]
183
+ end
184
+
180
185
  private
181
186
 
182
187
  def persist_acceptance_status_errors
183
188
  update(acceptance_status_errors: validator.errors)
184
189
  end
185
190
 
186
- def currency
187
- return_authorization.try(:currency) || Spree::Config[:currency]
188
- end
189
-
190
191
  def process_inventory_unit!
191
192
  inventory_unit.return!
192
193
 
@@ -225,6 +226,14 @@ module Spree
225
226
  end
226
227
  end
227
228
 
229
+ def belongs_to_return_authorization_order
230
+ return unless return_authorization && inventory_unit
231
+
232
+ if return_authorization.order_id != inventory_unit.order_id
233
+ errors.add(:base, I18n.t("spree.return_items_cannot_be_associated_with_multiple_orders"))
234
+ end
235
+ end
236
+
228
237
  def eligible_exchange_variant
229
238
  return unless exchange_variant && exchange_variant_id_changed?
230
239
  unless eligible_exchange_variants.include?(exchange_variant)
@@ -141,8 +141,11 @@ module Spree
141
141
  private
142
142
 
143
143
  def touch_ancestors_and_taxonomy
144
- # Touches all ancestors at once to avoid recursive taxonomy touch, and reduce queries.
145
- self.class.default_scoped.where(id: ancestors.pluck(:id)).update_all(updated_at: Time.current)
144
+ # Touches ancestors directly rather than through #touch to avoid a recursive taxonomy touch.
145
+ time = Time.current
146
+ self.class.default_scoped.where(id: ancestors.pluck(:id)).order(:id).each do |ancestor|
147
+ ancestor.update_column(:updated_at, time)
148
+ end
146
149
  # Have taxonomy touch happen in #touch_ancestors_and_taxonomy rather than association option in order for imports to override.
147
150
  taxonomy.try!(:touch)
148
151
  end
@@ -25,6 +25,6 @@ module Spree
25
25
  all
26
26
  }
27
27
 
28
- default_scope -> { order([default: :desc, updated_at: :desc]) }
28
+ default_scope -> { order([{ default: :desc, updated_at: :desc }]) }
29
29
  end
30
30
  end
@@ -25,6 +25,7 @@ module Spree
25
25
  def run
26
26
  # Early return if there is no VAT rates in the current store.
27
27
  return if !variant.tax_category || variant_vat_rates.empty?
28
+ return if variant.default_price&.amount.nil?
28
29
 
29
30
  country_isos_requiring_price.each do |country_iso|
30
31
  # Don't re-create the default price
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
5
  <meta name="viewport" content="width=device-width">
6
+ <%# The Ink CSS below is MIT licensed; see ink.license.txt in this directory. %>
6
7
  <style>
7
8
  /**********************************************
8
9
  * Ink v1.0.5 - Copyright 2013 ZURB Inc *
@@ -0,0 +1,28 @@
1
+ The mailer layout in this directory (base_mailer.html.erb) inlines the
2
+ CSS of Ink v1.0.5, ZURB's responsive email framework, from
3
+ https://github.com/foundation/foundation-emails (formerly zurb/ink).
4
+
5
+ --------------------------------------------------------------------------------
6
+
7
+ Copyright (c) 2013 ZURB, inc.
8
+
9
+ MIT License
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining
12
+ a copy of this software and associated documentation files (the
13
+ "Software"), to deal in the Software without restriction, including
14
+ without limitation the rights to use, copy, modify, merge, publish,
15
+ distribute, sublicense, and/or sell copies of the Software, and to
16
+ permit persons to whom the Software is furnished to do so, subject to
17
+ the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be
20
+ included in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -36,7 +36,6 @@ class AddAmountRemainingToStoreCreditEvents < ActiveRecord::Migration[5.0]
36
36
  # These actions do not change the amount_remaining so the previous
37
37
  # amount available is used (either the credit's amount or the
38
38
  # amount_remaining coming from the event right before this one).
39
- credit_amount
40
39
  when StoreCredit::AUTHORIZE_ACTION,
41
40
  StoreCredit::INVALIDATE_ACTION
42
41
  # These actions remove the amount from the available credit amount.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "4.6.2"
4
+ VERSION = "4.6.4"
5
5
 
6
6
  def self.solidus_version = VERSION
7
7
 
@@ -73,7 +73,7 @@ module Spree
73
73
 
74
74
  @@option_type_attributes = [:name, :presentation, option_values_attributes: option_value_attributes]
75
75
 
76
- @@payment_attributes = [:amount, :payment_method_id, :payment_method, customer_metadata: {}]
76
+ @@payment_attributes = [:payment_method_id, :payment_method, customer_metadata: {}]
77
77
 
78
78
  @@product_properties_attributes = [:property_name, :value, :position]
79
79
 
@@ -165,6 +165,7 @@ module Spree
165
165
 
166
166
  @@checkout_payment_attributes = [
167
167
  payments_attributes: payment_attributes + [
168
+ :amount,
168
169
  source_attributes:
169
170
  ]
170
171
  ]
@@ -2,7 +2,15 @@
2
2
 
3
3
  FactoryBot.define do
4
4
  factory :return_item, class: 'Spree::ReturnItem' do
5
- association(:inventory_unit, factory: :inventory_unit, state: :shipped)
5
+ inventory_unit do
6
+ # When a return authorization is given, the inventory unit must belong
7
+ # to the same order.
8
+ if __override_names__.include?(:return_authorization) && return_authorization&.order
9
+ association(:inventory_unit, state: :shipped, order: return_authorization.order)
10
+ else
11
+ association(:inventory_unit, state: :shipped)
12
+ end
13
+ end
6
14
  association(:return_reason, factory: :return_reason)
7
15
  return_authorization do |_return_item|
8
16
  build(:return_authorization, order: inventory_unit.order)
@@ -8,11 +8,11 @@ FactoryBot.define do
8
8
  action { Spree::StoreCredit::AUTHORIZE_ACTION }
9
9
 
10
10
  factory :store_credit_auth_event, class: 'Spree::StoreCreditEvent' do
11
- action { Spree::StoreCredit::AUTHORIZE_ACTION }
11
+ action { Spree::StoreCredit::AUTHORIZE_ACTION }
12
12
  end
13
13
 
14
14
  factory :store_credit_capture_event do
15
- action { Spree::StoreCredit::CAPTURE_ACTION }
15
+ action { Spree::StoreCredit::CAPTURE_ACTION }
16
16
  end
17
17
 
18
18
  factory :store_credit_adjustment_event do
@@ -10,7 +10,7 @@ module Spree
10
10
  def up_to(state, user: nil)
11
11
  # Need to create a valid zone too...
12
12
  @zone = ::FactoryBot.create(:zone)
13
- @country = ::FactoryBot.create(:country)
13
+ @country = Spree::Country.find_by(iso: "US") || ::FactoryBot.create(:country)
14
14
  @state = ::FactoryBot.create(:state, country: @country)
15
15
 
16
16
  @zone.members << Spree::ZoneMember.create(zoneable: @country)
@@ -0,0 +1,25 @@
1
+ This license covers the vendored jQuery.payment v1.3.2 (jquery.payment.js
2
+ in this directory), from https://github.com/stripe-archive/jquery.payment.
3
+
4
+ --------------------------------------------------------------------------------
5
+
6
+ Copyright (c) 2014 Stripe
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ "Software"), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ This license covers the vendored jsUri v1.1.1 (jsuri.js in this
2
+ directory), from https://github.com/derek-watson/jsUri.
3
+
4
+ --------------------------------------------------------------------------------
5
+
6
+ Copyright (c) 2014, Derek Watson
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.2
4
+ version: 4.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
@@ -768,6 +768,7 @@ files:
768
768
  - app/subscribers/spree/order_mailer_subscriber.rb
769
769
  - app/subscribers/spree/reimbursement_mailer_subscriber.rb
770
770
  - app/views/layouts/spree/base_mailer.html.erb
771
+ - app/views/layouts/spree/ink.license.txt
771
772
  - app/views/spree/carton_mailer/shipped_email.html.erb
772
773
  - app/views/spree/carton_mailer/shipped_email.text.erb
773
774
  - app/views/spree/order_mailer/cancel_email.html.erb
@@ -1070,7 +1071,9 @@ files:
1070
1071
  - lib/tasks/solidus/delete_prices_with_nil_amount.rake
1071
1072
  - solidus_core.gemspec
1072
1073
  - vendor/assets/javascripts/jquery.payment.js
1074
+ - vendor/assets/javascripts/jquery.payment.license.txt
1073
1075
  - vendor/assets/javascripts/jsuri.js
1076
+ - vendor/assets/javascripts/jsuri.license.txt
1074
1077
  - vendor/assets/stylesheets/normalize.css
1075
1078
  homepage: http://solidus.io
1076
1079
  licenses:
@@ -1114,7 +1117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1114
1117
  - !ruby/object:Gem::Version
1115
1118
  version: 1.8.23
1116
1119
  requirements: []
1117
- rubygems_version: 3.7.2
1120
+ rubygems_version: 4.0.10
1118
1121
  specification_version: 4
1119
1122
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
1120
1123
  test_files: []