Module: SolidusExtensionDevTools::TestingSupport::Preferences
- Defined in:
- lib/solidus_extension_dev_tools/testing_support/preferences.rb
Instance Method Summary collapse
-
#stub_spree_preferences(prefs_or_conf_class, prefs = nil) ⇒ Object
This wrapper method allows to stub spree preferences using the new standard way of solidus core but also works with old versions that does not have the stub_spree_preferences method yet.
Instance Method Details
#stub_spree_preferences(prefs_or_conf_class, prefs = nil) ⇒ Object
This wrapper method allows to stub spree preferences using the new standard way of solidus core but also works with old versions that does not have the stub_spree_preferences method yet. This way we can start using this method in our extensions safely.
To have this available, it is needed to require in the spec/spec_helper.rb of the extension both:
require ‘spree/testing_support/preferences’ require ‘solidus_extension_dev_tools/testing_support/preferences’
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solidus_extension_dev_tools/testing_support/preferences.rb', line 31 def stub_spree_preferences(prefs_or_conf_class, prefs = nil) super && return if SolidusExtensionDevTools.reset_spree_preferences_deprecated? if prefs_or_conf_class.is_a?(Hash) preference_store_class = Spree::Config preferences = prefs_or_conf_class else preference_store_class = prefs_or_conf_class preferences = prefs end preference_store_class.set(preferences) end |