solidus_core 3.2.5 → 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ca291cd7b979dea71a53e089ec1f5582fd29606135be6802668e6a249655295
4
- data.tar.gz: 35c97c39d287f13bd2330fef96e59eefa5d82869e49563a32706b827087a936a
3
+ metadata.gz: d2b38eb2401bb7f4cc38c7eadab97621ec03a74aab1083aaa838e7ac02a753f8
4
+ data.tar.gz: b6d75fd4b66ded6bbc9edbba1b89ecfdc112310e8aa430e4402bc6d82a4d82ef
5
5
  SHA512:
6
- metadata.gz: dcd03d7fe00dade48a32ff5862579eed61115afe17e225e0378ea83fb1af3c502467dbef833619159742b2b7cef998e53d47cde357d6e2b57beb73daa80708f2
7
- data.tar.gz: cea864acea70b4d18b208481ffa8d0587ce5bc721f2de5d83c653b2125e7dbf1e9da81ef0cb211180d48df93a53daaf813e5d8d7ecd9181c5c0f9de2efd239ba
6
+ metadata.gz: b383febf1f4b46763aca57b0cc491a66f9e5cd407579d302f9fdbf9421d9a61f9a6f0ab89c570c5a61bc444ab17a18e8b86ab3fe088a4ce4354cb3b0c22b1208
7
+ data.tar.gz: 351d24867375e4b103d49ab1fa084acea266af23a883f0d83005e574ef5d6fa51d07d39f9a6fe507298ddb403d2db6982ed204651649e21c0f7c3ab76db81b0b
@@ -32,6 +32,12 @@ module Spree
32
32
  prices.build(self.class.default_price_attributes)
33
33
  end
34
34
 
35
+ # @deprecated Use {#default_price_or_build} instead.
36
+ def find_or_build_default_price
37
+ default_price_or_build
38
+ end
39
+ deprecate find_or_build_default_price: :default_price_or_build, deprecator: Spree::Deprecation
40
+
35
41
  # Select from {#prices} the one to be considered as the default
36
42
  #
37
43
  # This method works with the in-memory association, so non-persisted prices
@@ -83,6 +83,7 @@ module Spree
83
83
  :height,
84
84
  :price,
85
85
  :sku,
86
+ :track_inventory,
86
87
  :weight,
87
88
  :width,
88
89
  ]
@@ -113,8 +113,7 @@ module Spree
113
113
  def amount_for_adjustment_label
114
114
  ActiveSupport::NumberHelper::NumberToPercentageConverter.convert(
115
115
  amount * 100,
116
- locale: I18n.locale,
117
- precision: nil
116
+ locale: I18n.locale
118
117
  )
119
118
  end
120
119
 
@@ -751,6 +751,10 @@ en:
751
751
  not_saved:
752
752
  one: '1 error prohibited this %{resource} from being saved:'
753
753
  other: "%{count} errors prohibited this %{resource} from being saved:"
754
+ number:
755
+ percentage:
756
+ format:
757
+ precision: 1
754
758
  spree:
755
759
  abbreviation: Abbreviation
756
760
  accept: Accept
@@ -8,7 +8,7 @@ module Solidus
8
8
  class UpdateGenerator < ::Rails::Generators::Base
9
9
  FROM = Spree.previous_solidus_minor_version
10
10
 
11
- desc 'Generates a new initializer to preview the new defaults for current Solidus version'
11
+ desc 'Generates a new initializer to preview the new defaults for current Solidus version and copy new migrations'
12
12
 
13
13
  source_root File.expand_path('templates', __dir__)
14
14
 
@@ -37,10 +37,15 @@ module Solidus
37
37
  default: 'config/initializers/',
38
38
  hide: true
39
39
 
40
+ class_option :install_migrations,
41
+ type: :boolean,
42
+ default: true,
43
+ hide: true
44
+
40
45
  def create_new_defaults_initializer
41
46
  previous_version_prompt = options[:previous_version_prompt]
42
47
  return if previous_version_prompt && !yes?(<<~MSG, :red)
43
- The update process is only supported if you are coming from version #{FROM}. If this is not the case, please, skip it and update your application to use Solidus #{FROM} before retrying.
48
+ The default preferences update process is only supported if you are coming from version #{FROM}. If this is not the case, please, skip it and update your application to use Solidus #{FROM} before retrying.
44
49
  If you are confident you want to upgrade from a previous version, you must rerun the generator with the "--from={OLD_VERSION}" argument.
45
50
  Are you sure you want to continue? (y/N)
46
51
  MSG
@@ -57,6 +62,13 @@ module Solidus
57
62
  File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb")
58
63
  end
59
64
 
65
+ def install_migrations
66
+ return unless options[:install_migrations]
67
+
68
+ say_status :copying, "migrations"
69
+ rake 'spree:install:migrations'
70
+ end
71
+
60
72
  def print_message
61
73
  say <<~MSG
62
74
 
data/lib/spree/bus.rb CHANGED
@@ -9,12 +9,12 @@ module Spree
9
9
  # It has some modifications to support internal usage of the legacy event
10
10
  # system {see Spree::AppConfiguration#use_legacy_events}.
11
11
  Bus = Omnes::Bus.new
12
- Bus.define_singleton_method(:publish) do |*args, **kwargs, &block|
12
+ def Bus.publish(event, **kwargs)
13
13
  if Spree::Config.use_legacy_events
14
- Spree::Event.fire(*args, **kwargs, &block)
14
+ Spree::Event.fire(event, **kwargs)
15
15
  else
16
16
  # Override caller_location to point to the actual event publisher
17
- super(*args, **kwargs, caller_location: caller_locations(1)[0], &block)
17
+ super(event, **kwargs, caller_location: caller_locations(1)[0])
18
18
  end
19
19
  end
20
20
  end
@@ -87,6 +87,7 @@ module Spree
87
87
 
88
88
  config.after_initialize do
89
89
  Spree::Config.check_load_defaults_called('Spree::Config')
90
+ Spree::Config.static_model_preferences.validate!
90
91
  end
91
92
 
92
93
  config.after_initialize do
@@ -45,7 +45,7 @@ module Spree
45
45
  new_master.sku = "COPY OF #{master.sku}"
46
46
  new_master.deleted_at = nil
47
47
  new_master.images = master.images.map { |image| duplicate_image image } if @include_images
48
- new_master.price = master.price
48
+ new_master.prices = master.prices.map(&:dup)
49
49
  end
50
50
  end
51
51
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "3.2.5"
4
+ VERSION = "3.2.7"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -7,13 +7,8 @@ module Spree
7
7
  attr_reader :preferences
8
8
 
9
9
  def initialize(klass, hash)
10
- hash = hash.symbolize_keys
11
- hash.keys.each do |key|
12
- if !klass.defined_preferences.include?(key)
13
- raise "Preference #{key.inspect} is not defined on #{klass}"
14
- end
15
- end
16
- @preferences = hash
10
+ @klass = klass
11
+ @preferences = hash.symbolize_keys
17
12
  end
18
13
 
19
14
  def fetch(key, &block)
@@ -27,6 +22,8 @@ module Spree
27
22
  def to_hash
28
23
  @preferences.deep_dup
29
24
  end
25
+
26
+ delegate :keys, to: :@preferences
30
27
  end
31
28
 
32
29
  def initialize
@@ -36,12 +33,32 @@ module Spree
36
33
  end
37
34
 
38
35
  def add(klass, name, preferences)
39
- @store[klass.to_s][name] = Definition.new(klass, preferences)
36
+ @store[klass.to_s][name] = Definition.new(klass.to_s, preferences)
40
37
  end
41
38
 
42
39
  def for_class(klass)
43
40
  @store[klass.to_s]
44
41
  end
42
+
43
+ def validate!
44
+ @store.keys.map(&:constantize).each do |klass|
45
+ validate_for_class!(klass)
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def validate_for_class!(klass)
52
+ for_class(klass).each do |name, preferences|
53
+ klass_keys = klass.defined_preferences.map(&:to_s)
54
+ extra_keys = preferences.keys.map(&:to_s) - klass_keys
55
+ next if extra_keys.empty?
56
+
57
+ raise \
58
+ "Unexpected keys found for #{klass} under #{name}: #{extra_keys.sort.join(', ')} " \
59
+ "(expected keys: #{klass_keys.sort.join(', ')})"
60
+ end
61
+ end
45
62
  end
46
63
  end
47
64
  end
@@ -90,7 +90,7 @@ module DummyApp
90
90
  config.active_record.dump_schema_after_migration = false
91
91
 
92
92
  # Configure active storage to use storage within tmp folder
93
- unless ENV['DISABLE_ACTIVE_STORAGE']
93
+ unless (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
94
94
  initializer 'solidus.active_storage' do
95
95
  config.active_storage.service_configurations = {
96
96
  test: {
@@ -138,9 +138,9 @@ Spree.user_class = 'Spree::LegacyUser'
138
138
  Spree.load_defaults(Spree.solidus_version)
139
139
  Spree.config do |config|
140
140
  config.mails_from = "store@example.com"
141
- config.use_legacy_events = ENV['USE_LEGACY_EVENTS'].present?
141
+ config.use_legacy_events = (ENV['USE_LEGACY_EVENTS'] == 'true')
142
142
 
143
- if ENV['DISABLE_ACTIVE_STORAGE']
143
+ if (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
144
144
  config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
145
145
  config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
146
146
  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: 3.2.5
4
+ version: 3.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-23 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -1023,7 +1023,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1023
1023
  - !ruby/object:Gem::Version
1024
1024
  version: 1.8.23
1025
1025
  requirements: []
1026
- rubygems_version: 3.3.26
1026
+ rubygems_version: 3.4.6
1027
1027
  signing_key:
1028
1028
  specification_version: 4
1029
1029
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.