spree_core 5.3.0 → 5.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d6583fe2ea61bf166c3e25d8739ea9b953b396c35acfbb4e47edde6d612d59d
4
- data.tar.gz: 3bc0a7d98a739e16e3857eabdf23cbb25a989f17cf7186ae0632ced2bff36ac4
3
+ metadata.gz: 8852343e0b0e126beaff8b5745ca76527a0c436344f670c2cdab2f27eeb1f23f
4
+ data.tar.gz: a3378bc532a952c8d72190c5ebfb244c07b103a8f4bb67ec3bcf889278395a45
5
5
  SHA512:
6
- metadata.gz: 66a7c9d1bbe53c07cf36032a2b61ebf850489a3e5b3e515c2916ad9bfa685b10e7a2bc7d8d0a5de1cb8241e7b96e0c31eb60de3351e306e6347a25f52032faf3
7
- data.tar.gz: 9dca332fe825e8342f9b2492bbd555e3d6b2868ae1a5a9f5f99a163d86efd28fba5c0bb63df74f9b304f1b2fb65f8aa9481bbca22c6757b13c7a05851c1d456e
6
+ metadata.gz: 893e2c5b7d12b76c599a35ed91df5062fb8849144c4dd34cfc528b59c7c8d993ef523e443d3aba36e949af5814f68105af80fc3caee9295919d53eb5fe3ed137
7
+ data.tar.gz: 81cdf22db519e0695e36363a097a0b6703e4bba5a44aff5989bb225d5ea2f16e1ffa087507c2af57254bdd1c3fd0b24b5649b56bca0ee8b38bc46bee59172041
@@ -57,6 +57,10 @@ module Spree
57
57
  #
58
58
  attribute :record_selection, :string, default: 'filtered'
59
59
 
60
+ def event_serializer_class
61
+ Spree::Events::ExportSerializer
62
+ end
63
+
60
64
  def done?
61
65
  attachment.present? && attachment.attached?
62
66
  end
@@ -196,7 +200,7 @@ module Spree
196
200
  def model_class
197
201
  klass = "Spree::#{to_s.demodulize.singularize}".safe_constantize
198
202
 
199
- raise NameError, "Missing model class for #{to_s}" unless klass
203
+ raise NameError, "Missing model class for #{self}" unless klass
200
204
 
201
205
  klass
202
206
  end
@@ -225,6 +225,10 @@ module Spree
225
225
  @current_ability ||= Spree.ability_class.new(user, { store: store })
226
226
  end
227
227
 
228
+ def event_serializer_class
229
+ Spree::Events::ImportSerializer
230
+ end
231
+
228
232
  class << self
229
233
  # Returns the available types for the import
230
234
  # @return [Array<Class>]
@@ -14,13 +14,17 @@ module Spree
14
14
  end
15
15
 
16
16
  def bill_address_id=(id)
17
+ return if bill_address_id == id
18
+
17
19
  address = Spree::Address.find_by(id: id)
18
- if address && address.user_id == user_id
20
+ # rubocop:disable Style/ConditionalAssignment
21
+ if address && user_id.present? && address.user_id == user_id
19
22
  self['bill_address_id'] = address.id
20
- bill_address.reload
21
23
  else
22
24
  self['bill_address_id'] = nil
23
25
  end
26
+ # rubocop:enable Style/ConditionalAssignment
27
+ reset_bill_address
24
28
  end
25
29
 
26
30
  def bill_address_attributes=(attributes)
@@ -29,13 +33,17 @@ module Spree
29
33
  end
30
34
 
31
35
  def ship_address_id=(id)
36
+ return if ship_address_id == id
37
+
32
38
  address = Spree::Address.find_by(id: id)
33
- if address && address.user_id == user_id
39
+ # rubocop:disable Style/ConditionalAssignment
40
+ if address && user_id.present? && address.user_id == user_id
34
41
  self['ship_address_id'] = address.id
35
- ship_address.reload
36
42
  else
37
43
  self['ship_address_id'] = nil
38
44
  end
45
+ # rubocop:enable Style/ConditionalAssignment
46
+ reset_ship_address
39
47
  end
40
48
 
41
49
  def ship_address_attributes=(attributes)
@@ -66,7 +66,10 @@ module Spree
66
66
  # @return [BigDecimal] The total amount of store credits applied to the order.
67
67
  def total_applied_store_credit
68
68
  if payments.loaded?
69
- payments.find_all(&:store_credit?).find_all(&:valid?).sum(&:amount) || BigDecimal::ZERO
69
+ payments.
70
+ find_all(&:store_credit?).
71
+ reject(&:has_invalid_state?).
72
+ sum(&:amount) || BigDecimal::ZERO
70
73
  else
71
74
  payments.store_credits.valid.sum(:amount)
72
75
  end
@@ -278,6 +278,10 @@ module Spree
278
278
  end
279
279
  end
280
280
 
281
+ def has_invalid_state?
282
+ INVALID_STATES.include?(state)
283
+ end
284
+
281
285
  private
282
286
 
283
287
  def set_amount
@@ -302,10 +306,6 @@ module Spree
302
306
  publish_event('payment.voided')
303
307
  end
304
308
 
305
- def has_invalid_state?
306
- INVALID_STATES.include?(state)
307
- end
308
-
309
309
  def validate_source
310
310
  if source && !source.valid?
311
311
  source.errors.map { |error| { field: error.attribute, message: error&.message } }.each do |err|
@@ -31,6 +31,10 @@ module Spree
31
31
  #
32
32
  has_one_attached :attachment, service: Spree.private_storage_service_name
33
33
 
34
+ def event_serializer_class
35
+ Spree::Events::ReportSerializer
36
+ end
37
+
34
38
  def self.report_type
35
39
  name.demodulize.underscore
36
40
  end
@@ -10,6 +10,7 @@ module Spree
10
10
  return failure(nil, error: 'No image link') if get_image_link(input[:variant], input[:product]).nil?
11
11
 
12
12
  information['id'] = input[:variant].id
13
+ information['item_group_id'] = input[:product].id
13
14
  information['title'] = format_title(input[:product], input[:variant])
14
15
  information['description'] = get_description(input[:product], input[:variant])
15
16
  information['link'] = "#{input[:store].url}/products/#{input[:product].slug}"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Applies a gift card to an order
3
4
  # under the hood it creates a store credit payment record and updates the gift card amount used
4
5
  # @param gift_card [Spree::GiftCard] the gift card to apply
@@ -16,6 +17,14 @@ module Spree
16
17
  # we shouldn't allow a gift card to be applied to an order with a different currency
17
18
  return failure(:gift_card_mismatched_currency) if gift_card.currency != order.currency
18
19
 
20
+ # gift card requires logged user
21
+ if gift_card.user.present?
22
+ # user must be logged in
23
+ return failure(:gift_card_customer_not_logged_in) if order.user.blank?
24
+ # user must be the same as the gift card user
25
+ return failure(:gift_card_mismatched_customer) if gift_card.user != order.user
26
+ end
27
+
19
28
  amount = [gift_card.amount_remaining, order.total].min
20
29
  store = order.store
21
30
 
@@ -1190,7 +1190,10 @@ en:
1190
1190
  gift_card_already_redeemed: The Gift Card has already been redeemed.
1191
1191
  gift_card_applied: The Gift Card was successfully applied to your order!
1192
1192
  gift_card_batch: Gift Card Batch
1193
+ gift_card_customer_not_logged_in: Gift Card cannot be applied with guest user.
1193
1194
  gift_card_expired: The Gift Card has expired.
1195
+ gift_card_mismatched_currency: Gift Card cannot be applied with current currency.
1196
+ gift_card_mismatched_customer: This gift card is associated with another user.
1194
1197
  gift_card_removed: The Gift Card was successfully removed from your order
1195
1198
  gift_card_using_store_credit_error: You can't apply the Gift Card after you applied the store credit.
1196
1199
  gift_cards: Gift Cards
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.3.0'.freeze
2
+ VERSION = '5.3.2'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -3,7 +3,7 @@ require 'generators/spree/dummy_model/dummy_model_generator'
3
3
 
4
4
  desc 'Generates a dummy app for testing'
5
5
  namespace :common do
6
- task :test_app, :user_class do |_t, args|
6
+ task :test_app, [:authentication, :user_class, :admin_user_class, :css, :javascript, :install_admin, :install_storefront] do |_t, args|
7
7
  args.with_defaults(
8
8
  authentication: 'dummy',
9
9
  user_class: 'Spree::LegacyUser',
@@ -20,8 +20,7 @@ namespace :common do
20
20
  javascript_enabled = args[:javascript].to_b
21
21
  css_enabled = args[:css].to_b
22
22
 
23
- # Admin and Storefront require JavaScript and CSS (Tailwind) to function properly
24
- javascript_enabled ||= install_admin || install_storefront
23
+ # Admin and Storefront require CSS (Tailwind) to function properly
25
24
  css_enabled ||= install_admin || install_storefront
26
25
 
27
26
  puts args
@@ -32,9 +31,6 @@ namespace :common do
32
31
  dummy_app_args = [
33
32
  "--lib_name=#{ENV['LIB_NAME']}"
34
33
  ]
35
- # Use API mode only if no frontend components are needed
36
- use_api_mode = !install_storefront && !install_admin && !javascript_enabled && !css_enabled
37
- dummy_app_args << '--api' if use_api_mode
38
34
  dummy_app_args << '--javascript' if javascript_enabled
39
35
  dummy_app_args << '--css=tailwind' if css_enabled
40
36
 
@@ -2,8 +2,21 @@ require 'spree/testing_support/common_rake'
2
2
 
3
3
  desc 'Generates a dummy app for testing an extension'
4
4
  namespace :extension do
5
- task :test_app, [:authentication, :user_class] do |_t, args|
5
+ task :test_app, [:options] do |_t, args|
6
6
  Spree::DummyGeneratorHelper.inject_extension_requirements = true
7
- Rake::Task['common:test_app'].execute(args)
7
+ # Support both hash passed as first arg and named options
8
+ options = args[:options].is_a?(Hash) ? args[:options] : args.to_h
9
+ Rake::Task['common:test_app'].execute(Rake::TaskArguments.new(
10
+ [:authentication, :user_class, :admin_user_class, :css, :javascript, :install_admin, :install_storefront],
11
+ [
12
+ options[:authentication],
13
+ options[:user_class],
14
+ options[:admin_user_class],
15
+ options[:css],
16
+ options[:javascript],
17
+ options[:install_admin],
18
+ options[:install_storefront]
19
+ ]
20
+ ))
8
21
  end
9
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 3.3.1
110
+ - !ruby/object:Gem::Dependency
111
+ name: benchmark
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: carmen
112
126
  requirement: !ruby/object:Gem::Requirement
@@ -1703,9 +1717,9 @@ licenses:
1703
1717
  - BSD-3-Clause
1704
1718
  metadata:
1705
1719
  bug_tracker_uri: https://github.com/spree/spree/issues
1706
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.0
1720
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.2
1707
1721
  documentation_uri: https://docs.spreecommerce.org/
1708
- source_code_uri: https://github.com/spree/spree/tree/v5.3.0
1722
+ source_code_uri: https://github.com/spree/spree/tree/v5.3.2
1709
1723
  rdoc_options: []
1710
1724
  require_paths:
1711
1725
  - lib
@@ -1720,7 +1734,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1720
1734
  - !ruby/object:Gem::Version
1721
1735
  version: 1.8.23
1722
1736
  requirements: []
1723
- rubygems_version: 4.0.2
1737
+ rubygems_version: 4.0.3
1724
1738
  specification_version: 4
1725
1739
  summary: The bare bones necessary for Spree
1726
1740
  test_files: []