solidus_core 2.9.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/preferences.rb +54 -15
- data/spec/models/spree/stock/quantifier_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2edabaa78d1ec9b196da1fe62c6597ea1fd392a37185f48c6786e6d00f4566a
|
4
|
+
data.tar.gz: fb268588d3df1204706a1d89026b9de2b5967f5b9d5c3bcce91c52e05280a0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 521bcc28081f5ad38b84736fa159e616fd22985b1ccf2022921945533dc00144b9688827fd1405b70212de8cc222b1482eac7f143f4b71f729c931a4bea319c4
|
7
|
+
data.tar.gz: e9a8edbd1fe694e5dd4d823d08dff30db1e036212c37837421702b9e31514db48fa1b5f58441b46a490c96d171dfe1964a776b13477826160b2f01ac24fbaa8e
|
data/lib/spree/core/version.rb
CHANGED
@@ -44,21 +44,36 @@ module Spree
|
|
44
44
|
# This method may be used for stubbing one or more different preferences
|
45
45
|
# at the same time.
|
46
46
|
#
|
47
|
-
# @param [Hash]
|
47
|
+
# @param prefs_or_conf_class [Class, Hash] the class we want to stub
|
48
|
+
# preferences for or the preferences hash (see prefs param). If this
|
49
|
+
# param is an Hash, preferences will be stubbed on Spree::Config.
|
50
|
+
# @param prefs [Hash, nil] names and values to be stubbed
|
48
51
|
#
|
49
|
-
# @example Stubs `currency` and `track_inventory_levels`
|
52
|
+
# @example Stubs `currency` and `track_inventory_levels` on `Spree::Config`:
|
50
53
|
# stub_spree_preferences(currency: 'EUR', track_inventory_levels: false)
|
51
54
|
# expect(Spree::Config.currency).to eql 'EUR'
|
52
55
|
#
|
56
|
+
# @example Stubs `locale` preference on `Spree::Backend::Config`:
|
57
|
+
# stub_spree_preferences(Spree::Backend::Config, locale: 'fr'),
|
58
|
+
# expect(Spree::Backend::Config.locale).to eql 'fr'
|
59
|
+
#
|
53
60
|
# @see https://github.com/solidusio/solidus/issues/3219
|
54
61
|
# Solidus #3219 for more details and motivations.
|
55
|
-
def stub_spree_preferences(
|
62
|
+
def stub_spree_preferences(prefs_or_conf_class, prefs = nil)
|
63
|
+
if prefs_or_conf_class.is_a?(Hash)
|
64
|
+
preference_store_class = Spree::Config
|
65
|
+
preferences = prefs_or_conf_class
|
66
|
+
else
|
67
|
+
preference_store_class = prefs_or_conf_class
|
68
|
+
preferences = prefs
|
69
|
+
end
|
70
|
+
|
56
71
|
preferences.each do |name, value|
|
57
|
-
if
|
58
|
-
allow(
|
72
|
+
if preference_store_class.method(:[]).owner >= preference_store_class.class
|
73
|
+
allow(preference_store_class).to receive(:[]).and_call_original
|
59
74
|
end
|
60
|
-
allow(
|
61
|
-
allow(
|
75
|
+
allow(preference_store_class).to receive(:[]).with(name) { value }
|
76
|
+
allow(preference_store_class).to receive(name) { value }
|
62
77
|
end
|
63
78
|
end
|
64
79
|
|
@@ -75,12 +90,30 @@ module Spree
|
|
75
90
|
# expect(Spree::Config.currency).to eql 'EUR'
|
76
91
|
# end
|
77
92
|
# @see Spree::TestingSupport::Preferences#stub_spree_preferences
|
78
|
-
def with_unfrozen_spree_preference_store
|
79
|
-
frozen_store =
|
80
|
-
|
93
|
+
def with_unfrozen_spree_preference_store(preference_store_class: Spree::Config)
|
94
|
+
frozen_store = preference_store_class.preference_store
|
95
|
+
preference_store_class.preference_store = preference_store_class[:unfrozen_preference_store].dup
|
81
96
|
yield
|
82
97
|
ensure
|
83
|
-
|
98
|
+
preference_store_class.preference_store = frozen_store
|
99
|
+
end
|
100
|
+
|
101
|
+
# This class method allows to freeze preferences for a specific
|
102
|
+
# configuration store class. It also stores the current state into
|
103
|
+
# a new preference of that store, so it can be reused when needed
|
104
|
+
# (eg. with_unfrozen_spree_preference_store)
|
105
|
+
#
|
106
|
+
# It is meant to be used by extensions as well, for example if one
|
107
|
+
# extension has its own Spree::ExtensionName::Config class, we can
|
108
|
+
# freeze it and be sure we always stub values on it during tests.
|
109
|
+
#
|
110
|
+
# @param preference_store_class [Class] the configuration class we want
|
111
|
+
# to freeze.
|
112
|
+
def self.freeze_preferences(preference_store_class)
|
113
|
+
config_class = preference_store_class.class
|
114
|
+
config_class.preference :unfrozen_preference_store, :hash
|
115
|
+
preference_store_class.unfrozen_preference_store = preference_store_class.preference_store.dup
|
116
|
+
preference_store_class.preference_store.freeze
|
84
117
|
end
|
85
118
|
end
|
86
119
|
end
|
@@ -88,9 +121,15 @@ end
|
|
88
121
|
|
89
122
|
RSpec.configure do |config|
|
90
123
|
config.before :suite do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
124
|
+
%w[
|
125
|
+
Spree::Config
|
126
|
+
Spree::Frontend::Config
|
127
|
+
Spree::Backend::Config
|
128
|
+
Spree::Api::Config
|
129
|
+
].each do |configuration_class|
|
130
|
+
if Object.const_defined?(configuration_class)
|
131
|
+
Spree::TestingSupport::Preferences.freeze_preferences(configuration_class.constantize)
|
132
|
+
end
|
133
|
+
end
|
95
134
|
end
|
96
135
|
end
|
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'when track_inventory_levels is false' do
|
30
|
-
before { stub_spree_preferences
|
30
|
+
before { stub_spree_preferences(track_inventory_levels: false) }
|
31
31
|
|
32
32
|
specify { expect(subject.total_on_hand).to eq(Float::INFINITY) }
|
33
33
|
|
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: 2.9.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07
|
11
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|