solidus_support 0.3.1 → 0.3.2

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: f6db8de62847880d849391cac8bea93fd39c63f32738a41121c910ec38694656
4
- data.tar.gz: 516068e598452089f9c93f07e30f7578d333c5e1620436c39e4ab2a49bacda82
3
+ metadata.gz: 2a5f84a7e9a295729e40c8c97377d6708dfcafc30125d4073a49bda3219ae78d
4
+ data.tar.gz: 194b7b5e8948f66e0cf5cf546c9036c95dc775f0efcda01f48a69a126acb889f
5
5
  SHA512:
6
- metadata.gz: '09bfa6215ef8559a804ad22cb2647d30a3830f26c56473640c8a6e9ae1053e05b1344d851767c0c371bdf709c1dda8b7ae35553538274dc8f3c61f58b355e412'
7
- data.tar.gz: 26b40f4ac3842128c218fce132b989eceeb9a9d21ada007858990aca34cd5b7bc9228071068b5e111fa0198d4f454ee8943129c08f501b7d033e4604066b6bf8
6
+ metadata.gz: a33ff02d178bf70be2bef2b02b20e9dc430b3fdc66478651fd014f2c7a3fbb9ad4b777c028b44a62c9292e9fc1177f4f75375c2076d8df529460c98473648492
7
+ data.tar.gz: cb26ee4a8a527898d9eb9c94a1a97210036cd74d42f7eb7e008ffd294445eebeafc0679b91e9cfeebe57edff5930d611c60910af6c37af87cc8106876c55fc54
@@ -16,6 +16,11 @@ module SolidusSupport
16
16
  end
17
17
  end
18
18
 
19
+ def reset_spree_preferences_deprecated?
20
+ first_version_without_reset = Gem::Requirement.new('>= 2.9')
21
+ first_version_without_reset.satisfied_by?(solidus_gem_version)
22
+ end
23
+
19
24
  def new_gateway_code?
20
25
  first_version_with_new_gateway_code = Gem::Requirement.new('>= 2.3')
21
26
  first_version_with_new_gateway_code.satisfied_by?(solidus_gem_version)
@@ -15,6 +15,7 @@ require 'spree/testing_support/authorization_helpers'
15
15
  require 'spree/testing_support/factories'
16
16
  require 'spree/testing_support/url_helpers'
17
17
  require 'spree/testing_support/preferences'
18
+ require 'solidus_support/testing_support/preferences'
18
19
 
19
20
  RSpec.configure do |config|
20
21
  config.include FactoryBot::Syntax::Methods
@@ -24,6 +25,7 @@ RSpec.configure do |config|
24
25
  config.include Spree::TestingSupport::UrlHelpers
25
26
 
26
27
  config.include Spree::TestingSupport::Preferences
28
+ config.include SolidusSupport::TestingSupport::Preferences
27
29
 
28
30
  config.before :suite do
29
31
  DatabaseCleaner.clean_with :truncation
@@ -35,7 +37,7 @@ RSpec.configure do |config|
35
37
  DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
36
38
 
37
39
  DatabaseCleaner.cleaning do
38
- reset_spree_preferences
40
+ reset_spree_preferences unless SolidusSupport.reset_spree_preferences_deprecated?
39
41
 
40
42
  example.run
41
43
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusSupport
4
+ module TestingSupport
5
+ module Preferences
6
+ # This wrapper method allows to stub spree preferences using
7
+ # the new standard way of solidus core but also works with
8
+ # old versions that does not have the stub_spree_preferences
9
+ # method yet. This way we can start using this method in our
10
+ # extensions safely.
11
+ #
12
+ # To have this available, it is needed to require in the
13
+ # spec/spec_helper.rb of the extension both:
14
+ #
15
+ # require 'spree/testing_support/preferences'
16
+ # require 'solidus_support/testing_support/preferences'
17
+ #
18
+ # @example Set a preference on Spree::Config
19
+ # stub_spree_preferences(allow_guest_checkout: false)
20
+ #
21
+ # @example Set a preference on Spree::Api::Config
22
+ # stub_spree_preferences(Spree::Api::Config, requires_authentication: false)
23
+ #
24
+ # @example Set a preference on a custom Spree::CustomExtension::Config
25
+ # stub_spree_preferences(Spree::CustomExtension::Config, custom_pref: true)
26
+ #
27
+ # @param prefs_or_conf_class [Class, Hash] the class we want to stub
28
+ # preferences for or the preferences hash (see prefs param). If this
29
+ # param is an Hash, preferences will be stubbed on Spree::Config.
30
+ # @param prefs [Hash, nil] names and values to be stubbed
31
+ def stub_spree_preferences(prefs_or_conf_class, prefs = nil)
32
+ super && return if SolidusSupport.reset_spree_preferences_deprecated?
33
+
34
+ if prefs_or_conf_class.is_a?(Hash)
35
+ preference_store_class = Spree::Config
36
+ preferences = prefs_or_conf_class
37
+ else
38
+ preference_store_class = prefs_or_conf_class
39
+ preferences = prefs
40
+ end
41
+ preference_store_class.set(preferences)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module SolidusSupport
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rubocop'
24
24
  spec.add_development_dependency 'rubocop-rspec'
25
25
  spec.add_development_dependency 'solidus_core'
26
+ spec.add_dependency 'capybara-screenshot'
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-17 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: capybara-screenshot
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Collection of common functionality for solidus extensions
98
112
  email:
99
113
  - john@stembolt.com
@@ -113,6 +127,7 @@ files:
113
127
  - lib/solidus_support/extension/rails_helper.rb
114
128
  - lib/solidus_support/extension/spec_helper.rb
115
129
  - lib/solidus_support/migration.rb
130
+ - lib/solidus_support/testing_support/preferences.rb
116
131
  - lib/solidus_support/version.rb
117
132
  - solidus_support.gemspec
118
133
  - spec/solidus_support_spec.rb