diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/rubocop/cop/static_translation_definition_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/rubocop/cop/static_translation_definition_spec.rb')
-rw-r--r-- | spec/rubocop/cop/static_translation_definition_spec.rb | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/spec/rubocop/cop/static_translation_definition_spec.rb b/spec/rubocop/cop/static_translation_definition_spec.rb index 554a7c17a4b..372fc194c56 100644 --- a/spec/rubocop/cop/static_translation_definition_spec.rb +++ b/spec/rubocop/cop/static_translation_definition_spec.rb @@ -9,11 +9,7 @@ require_relative '../../../rubocop/cop/static_translation_definition' RSpec.describe RuboCop::Cop::StaticTranslationDefinition do using RSpec::Parameterized::TableSyntax - let(:msg) do - "The text you're translating will be already in the translated form when it's assigned to the constant. " \ - "When a users changes the locale, these texts won't be translated again. " \ - "Consider moving the translation logic to a method." - end + let(:msg) { described_class::MSG } subject(:cop) { described_class.new } @@ -62,7 +58,7 @@ RSpec.describe RuboCop::Cop::StaticTranslationDefinition do } end CODE - <<~CODE + <<~CODE, class MyClass B = [ [ @@ -72,6 +68,26 @@ RSpec.describe RuboCop::Cop::StaticTranslationDefinition do ] end CODE + <<~CODE, + class MyClass + field :foo, title: _('A title') + ^^^^^^^^^^^^ #{msg} + end + CODE + <<~CODE + included do + _('a') + ^^^^^^ #{msg} + end + prepended do + self.var = _('a') + ^^^^^^ #{msg} + end + class_methods do + _('a') + ^^^^^^ #{msg} + end + CODE ] end @@ -95,6 +111,13 @@ RSpec.describe RuboCop::Cop::StaticTranslationDefinition do CODE <<~CODE, class MyClass + def self.method + @cache ||= { hello: proc { _("hello") } } + end + end + CODE + <<~CODE, + class MyClass def method @cache ||= { hello: _("hello") } end @@ -128,13 +151,30 @@ RSpec.describe RuboCop::Cop::StaticTranslationDefinition do end end CODE - <<~CODE + <<~CODE, Struct.new('SomeClass') do def text _('Some translated text') end end CODE + <<~CODE, + class MyClass + field :foo, title: -> { _('A title') } + end + CODE + <<~CODE + included do + put do + _('b') + end + end + class_methods do + expose do + _('b') + end + end + CODE ] end |