spree_core 4.4.0.rc2 → 4.4.0

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: 6068db45525230da41ca606788cebd91ab374323e4e74497da8be61f0078d708
4
- data.tar.gz: 0d2d9dd7d2f9e100e410a71704e231f97e4be1fe7ada6f468ceb783d9780bcac
3
+ metadata.gz: a07abab7dbe8d8b60a019e561b5668c3f336a7eb6970336b6a94b47046837fc1
4
+ data.tar.gz: 212b678f9f9df3a4de9de428bd9291fc87cd1f7020ed0c7f50b97c81fbd68a08
5
5
  SHA512:
6
- metadata.gz: db2b58e61632b424a69e058b882daef3713d05d39bd49d818432a3028eab14d8ee4817fa8ca94633b71c287cca77ef9b2ad40c959d34a1e978da5be1b0ad6a37
7
- data.tar.gz: '08cc33ae6f5f6e8917d94b26831342bf9e7cc1db94db85923d1d01fd1c06ed323b983d64d90725697c42f938a952a0127799cf98b06937b74cb9416171dee0f6'
6
+ metadata.gz: 81e442e30106ce5756519d41717004ebcff0e6219f0e6fcfb563b3133b5635e5bde772ea3939edffac037f55f2eda42ca8ee69da69feb6f44f79d96f60fc4392
7
+ data.tar.gz: 02dd0236576e01b96c237d1989fee5a4ef669f4f4e39764b0a2ebbae26ad3847aca21915e0c6196a60088aa5f76bb817d6b478f9b04459d873f8508c00814b66
@@ -3,8 +3,21 @@ module Spree
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- store :public_metadata, coder: JSON
7
- store :private_metadata, coder: JSON
6
+ attribute :public_metadata, default: {} if Rails.version.to_f >= 6.1
7
+ attribute :private_metadata, default: {} if Rails.version.to_f >= 6.1
8
+ serialize :public_metadata, HashSerializer
9
+ serialize :private_metadata, HashSerializer
10
+ end
11
+
12
+ # https://nandovieira.com/using-postgresql-and-jsonb-with-ruby-on-rails
13
+ class HashSerializer
14
+ def self.dump(hash)
15
+ hash
16
+ end
17
+
18
+ def self.load(hash)
19
+ (hash || {}).with_indifferent_access
20
+ end
8
21
  end
9
22
  end
10
23
  end
@@ -19,6 +19,8 @@ module Spree::Preferences
19
19
  value = convert_preference_value(value, type)
20
20
  preferences[name] = value
21
21
 
22
+ ActiveSupport::Deprecation.warn("`#{name}` is deprecated. #{deprecated}") if deprecated
23
+
22
24
  # If this is an activerecord object, we need to inform
23
25
  # ActiveRecord::Dirty that this value has changed, since this is an
24
26
  # in-place update to the preferences hash.
@@ -134,13 +134,6 @@ module Spree
134
134
  Migrations.new(config, engine_name).check
135
135
  end
136
136
 
137
- initializer 'spree.core.checking_deprecated_preferences' do
138
- Spree::Config.deprecated_preferences.each do |pref|
139
- # FIXME: we should only notify about deprecated preferences that are in use, not all of them
140
- # warn "[DEPRECATION] Spree::Config[:#{pref[:name]}] is deprecated. #{pref[:message]}"
141
- end
142
- end
143
-
144
137
  config.to_prepare do
145
138
  # Ensure spree locale paths are present before decorators
146
139
  I18n.load_path.unshift(*(Dir.glob(
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '4.4.0.rc2'.freeze
2
+ VERSION = '4.4.0'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -4,10 +4,13 @@ shared_examples_for 'metadata' do |factory: described_class.name.demodulize.unde
4
4
  it { expect(subject.has_attribute?(:public_metadata)).to be_truthy }
5
5
  it { expect(subject.has_attribute?(:private_metadata)).to be_truthy }
6
6
 
7
- it { expect(subject.public_metadata.class).to eq(HashWithIndifferentAccess) }
8
- it { expect(subject.private_metadata.class).to eq(HashWithIndifferentAccess) }
7
+ it { expect(subject.public_metadata).to eq({}) }
8
+ it { expect(subject.private_metadata).to eq({}) }
9
9
 
10
- it do
10
+ it { expect(subject.public_metadata.class).to eq(ActiveSupport::HashWithIndifferentAccess) }
11
+ it { expect(subject.private_metadata.class).to eq(ActiveSupport::HashWithIndifferentAccess) }
12
+
13
+ it 'reads data as symbolized keys' do
11
14
  string = subject.public_metadata[:color] = 'red'
12
15
  number = subject.public_metadata[:priority] = 1
13
16
  array = subject.public_metadata[:keywords] = ['k1', 'k2']
@@ -20,4 +23,32 @@ shared_examples_for 'metadata' do |factory: described_class.name.demodulize.unde
20
23
  expect(subject.public_metadata[:keywords]).to eq(array)
21
24
  expect(subject.public_metadata[:additional_data]).to eq(hash.stringify_keys)
22
25
  end
26
+
27
+ it 'reads data as not symbolized keys' do
28
+ string = subject.public_metadata[:color] = 'red'
29
+ number = subject.public_metadata[:priority] = 1
30
+ array = subject.public_metadata[:keywords] = ['k1', 'k2']
31
+ hash = subject.public_metadata[:additional_data] = { size: 'big', material: 'wool' }
32
+
33
+ subject.save!
34
+
35
+ expect(subject.public_metadata['color']).to eq(string)
36
+ expect(subject.public_metadata['priority']).to eq(number)
37
+ expect(subject.public_metadata['keywords']).to eq(array)
38
+ expect(subject.public_metadata['additional_data']).to eq(hash.stringify_keys)
39
+ end
40
+
41
+ it 'can query records by metadata properties', skip: ENV['DB'] == 'mysql' do
42
+ subject.public_metadata[:color] = 'red'
43
+ subject.public_metadata[:priority] = 1
44
+ subject.public_metadata[:keywords] = ['k1', 'k2']
45
+ subject.public_metadata[:additional_data] = { size: 'big', material: 'wool' }
46
+
47
+ subject.save!
48
+
49
+ expect(described_class.where("public_metadata->>'color' = ?", 'red').count).to eq(1)
50
+ expect(described_class.where("public_metadata->>'priority' = ?", '1').count).to eq(1)
51
+ expect(described_class.where("public_metadata -> 'keywords' ? :keyword", keyword: 'k1').count).to eq(1)
52
+ expect(described_class.where("public_metadata -> 'additional_data' ->> 'size' = :size", size: 'big').count).to eq(1)
53
+ end
23
54
  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: 4.4.0.rc2
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-10 00:00:00.000000000 Z
12
+ date: 2022-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -977,9 +977,9 @@ licenses:
977
977
  - BSD-3-Clause
978
978
  metadata:
979
979
  bug_tracker_uri: https://github.com/spree/spree/issues
980
- changelog_uri: https://github.com/spree/spree/releases/tag/v4.4.0.rc2
980
+ changelog_uri: https://github.com/spree/spree/releases/tag/v4.4.0
981
981
  documentation_uri: https://dev-docs.spreecommerce.org/
982
- source_code_uri: https://github.com/spree/spree/tree/v4.4.0.rc2
982
+ source_code_uri: https://github.com/spree/spree/tree/v4.4.0
983
983
  post_install_message:
984
984
  rdoc_options: []
985
985
  require_paths: