From b227c78aeb078d79a41d15247fcabaf8b93e5e11 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 22 Aug 2020 18:13:21 +0100 Subject: [PATCH] Fix rubocop issues --- spec/support/i18n_translations_checker.rb | 19 ++++++++++--------- spec/support/preferences_helper.rb | 4 +++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/spec/support/i18n_translations_checker.rb b/spec/support/i18n_translations_checker.rb index 786e2f1cf9..a722f13302 100644 --- a/spec/support/i18n_translations_checker.rb +++ b/spec/support/i18n_translations_checker.rb @@ -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 - diff --git a/spec/support/preferences_helper.rb b/spec/support/preferences_helper.rb index 6563c6b27d..b69f5e8215 100644 --- a/spec/support/preferences_helper.rb +++ b/spec/support/preferences_helper.rb @@ -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