mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-14 23:47:48 +00:00
Fix rubocop issues
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This file exists solely to test whether or not there are missing translations
|
||||
# within the code that Spree's test suite covers.
|
||||
#
|
||||
@@ -49,29 +51,29 @@ module Spree
|
||||
self.used_translations ||= []
|
||||
self.unused_translation_messages = []
|
||||
self.unused_translations = []
|
||||
self.load_translations(translations)
|
||||
load_translations(translations)
|
||||
translation_diff = unused_translations - used_translations
|
||||
translation_diff.each do |translation|
|
||||
Spree.unused_translation_messages << "#{translation} (#{I18n.locale})"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.load_translations(hash, root=[])
|
||||
hash.each do |k,v|
|
||||
def self.load_translations(hash, root = [])
|
||||
hash.each do |k, v|
|
||||
if v.is_a?(Hash)
|
||||
load_translations(v, root.dup << k)
|
||||
else
|
||||
key = (root + [k]).join('.')
|
||||
self.unused_translations << key
|
||||
unused_translations << key
|
||||
end
|
||||
end
|
||||
end
|
||||
private_class_method :load_translations
|
||||
|
||||
def self.translations
|
||||
@translations ||= I18n.backend.send(:translations)[I18n.locale][:spree]
|
||||
@translations ||= I18n.backend.__send__(:translations)[I18n.locale][:spree]
|
||||
end
|
||||
private_class_method :translations
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
@@ -86,7 +88,7 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
Spree.check_unused_translations
|
||||
if false && Spree.unused_translation_messages.any?
|
||||
if Spree.unused_translation_messages.any?
|
||||
puts "\nThere are unused translations within Spree:"
|
||||
puts Spree.unused_translation_messages.sort
|
||||
exit(1)
|
||||
@@ -94,4 +96,3 @@ RSpec.configure do |config|
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PreferencesHelper
|
||||
# Resets all preferences to default values, you can
|
||||
# pass a block to override the defaults with a block
|
||||
@@ -11,7 +13,7 @@ module PreferencesHelper
|
||||
Spree::Preferences::Store.instance.clear_cache
|
||||
|
||||
config = Rails.application.config.spree.preferences
|
||||
configure_spree_preferences &config_block if block_given?
|
||||
configure_spree_preferences(&config_block) if block_given?
|
||||
end
|
||||
|
||||
def configure_spree_preferences
|
||||
|
||||
Reference in New Issue
Block a user