solidus_core 4.7.2 → 4.7.3

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: d3d8242467851026fff5d6e6c31639174974d747193e9bef00a77acbd7c6e912
4
- data.tar.gz: 7336f44aad6dc32d2d477acffe0de1af5acb1df5fa7bd399b3b754e3647269e3
3
+ metadata.gz: 6016be6a4a01809df118c168c5dd345f73ed968f3ad53262c45594680491d4cb
4
+ data.tar.gz: 64faf68ec42068af0ca862a72f5253fd1f72c99b12b0616178d10c11879e550a
5
5
  SHA512:
6
- metadata.gz: e0521407fa49fac2011d849d4fa08f03a165c32751ffdda07656dd985c3aa73a3ea0b90e4d7b6dfc7157a310fc371d3195b9e7e3f1d1b1b517d3c927370d01c8
7
- data.tar.gz: 4619fdf8d485b61ba1610d4c579fd83f82e4f0710648719b07c4ec4e246915a6d2de458f351560c375b212c84a37db01d9b9463608f1f141e27e531e363a958f
6
+ metadata.gz: c9b6182a1739ef955f53359f927874aee7bcbed451362e4d228b32ee9526ace50bddca9816fa9383662c41352824a03dcbe6a5d6064ab085271a56c0ae02d7bd
7
+ data.tar.gz: cc30e67a19c56e0f0948501a813e2bdf3810eb19e08ecf18482c771aeff678217d4eb4b1ff050a2f92688cd36bfbb1ca3c55e037fcda9bed71fa4edd04e385c0
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  # Base class for all Solidus background jobs
5
- class BaseJob < ActiveJob::Base # rubocop:disable Rails/ApplicationJob
5
+ class BaseJob < ActiveJob::Base
6
6
  # Automatically retry jobs that encountered a deadlock
7
7
  retry_on ActiveRecord::Deadlocked
8
8
 
@@ -321,8 +321,15 @@ module Spree
321
321
 
322
322
  # Associates the specified user with the order.
323
323
  def associate_user!(user, override_email = true)
324
+ user_changed = user_id != user.try(:id)
324
325
  self.user = user
325
326
  attrs_to_set = {user_id: user.try(:id)}
327
+
328
+ if user_changed
329
+ self.guest_token = nil
330
+ attrs_to_set[:guest_token] = create_token
331
+ end
332
+
326
333
  attrs_to_set[:email] = user.try(:email) if override_email
327
334
  attrs_to_set[:created_by_id] = user.try(:id) if created_by.blank?
328
335
 
@@ -11,7 +11,7 @@ module Spree
11
11
  # * :gateway_customer_profile_id, :gateway_payment_profile_id (String): Gateway
12
12
  # identifiers for a new {CreditCard}, e.g. a one-time token. Raises
13
13
  # ActiveRecord::RecordNotFound if either already belongs to a {CreditCard}
14
- # owned by a different user.
14
+ # owned by a different user or order.
15
15
  # @param request_env [Hash] rack env of user creating the payment
16
16
  # @param payment [Payment] Internal use only. Instead of making a new payment, change the attributes for an existing one.
17
17
  def initialize(order, attributes, payment: nil, request_env: {})
@@ -57,11 +57,11 @@ module Spree
57
57
  end
58
58
  end
59
59
 
60
- # Gateway profile ids may only be submitted for a new source when they are
60
+ # Gateway profile IDs may only be submitted for a new source when they are
61
61
  # unknown to the store (e.g. a one-time token) or already belong to the
62
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.
63
+ # different user or no user, so customers cannot pay with another
64
+ # customer's stored gateway credential.
65
65
  def ensure_gateway_profile_ownership!(source_class)
66
66
  return unless source_class <= Spree::CreditCard
67
67
 
@@ -69,8 +69,10 @@ module Spree
69
69
  value = source_attributes[attribute]
70
70
  next if value.blank?
71
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
72
+ foreign_cards = Spree::CreditCard.where(attribute => value)
73
+ if order&.user_id
74
+ foreign_cards = foreign_cards.where(user_id: nil).or(foreign_cards.where.not(user_id: order.user_id))
75
+ end
74
76
  raise ActiveRecord::RecordNotFound if foreign_cards.exists?
75
77
  end
76
78
  end
@@ -25,7 +25,7 @@ module Spree
25
25
  self.allowed_ransackable_attributes = %w[name url code]
26
26
 
27
27
  before_save :ensure_default_exists_and_is_unique
28
- before_destroy :validate_not_default
28
+ before_destroy :validate_not_default, prepend: true
29
29
 
30
30
  enum :reverse_charge_status, {
31
31
  disabled: 0,
@@ -73,6 +73,7 @@ module Spree
73
73
  def validate_not_default
74
74
  if default
75
75
  errors.add(:base, :cannot_destroy_default_store)
76
+ throw :abort
76
77
  end
77
78
  end
78
79
  end
@@ -4,9 +4,7 @@ begin
4
4
  user_class.classify.constantize
5
5
  rescue NameError
6
6
  say_status :error, "Can't find an existing user class named #{user_class.classify}, plese set up one before using this authentication option.", :red
7
- # rubocop:disable Rails/Exit
8
7
  abort
9
- # rubocop:enable Rails/Exit
10
8
  end
11
9
 
12
10
  generate "spree:custom_user #{user_class.shellescape}"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "4.7.2"
4
+ VERSION = "4.7.3"
5
5
 
6
6
  def self.solidus_version = VERSION
7
7
 
@@ -111,5 +111,9 @@ module Spree::Preferences
111
111
  def allowed_admin_form_preference_types
112
112
  DEFAULT_ADMIN_FORM_PREFERENCE_TYPES
113
113
  end
114
+
115
+ def permitted_preference_attributes
116
+ new.admin_form_preference_names.map { |name| :"preferred_#{name}" }
117
+ end
114
118
  end
115
119
  end
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.7.2
4
+ version: 4.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team