Fix rubocop issues

This commit is contained in:
Luis Ramos
2020-08-22 18:13:21 +01:00
parent a44d0f7af6
commit b227c78aeb
2 changed files with 13 additions and 10 deletions

View File

@@ -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

View File

@@ -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