Browse Source

Maintenance: Bump rubocop from 1.22.3 to 1.23.0

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.22.3 to 1.23.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.22.3...v1.23.0)
Martin Gruner 3 years ago
parent
commit
e1750ef7e1

+ 1 - 1
Gemfile.lock

@@ -504,7 +504,7 @@ GEM
       rspec-support (~> 3.10)
     rspec-support (3.10.2)
     rszr (0.5.2)
-    rubocop (1.22.3)
+    rubocop (1.23.0)
       parallel (~> 1.10)
       parser (>= 3.0.0.0)
       rainbow (>= 2.2.2, < 4.0)

+ 2 - 1
app/models/channel/email_parser.rb

@@ -8,6 +8,7 @@ class Channel::EmailParser
   RECIPIENT_FIELDS = %w[to cc delivered-to x-original-to envelope-to].freeze
   SENDER_FIELDS = %w[from reply-to return-path sender].freeze
   EXCESSIVE_LINKS_MSG = __('This message cannot be displayed because it contains over 5,000 links. Download the raw message below and open it via an Email client if you still wish to view it.').freeze
+  MESSAGE_STRUCT = Struct.new(:from_display_name, :subject, :msg_size).freeze
 
 =begin
 
@@ -927,7 +928,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
     parsed_incoming_mail = Channel::EmailParser.new.parse(raw_incoming_mail)
 
     # construct a dummy mail object
-    mail = OpenStruct.new
+    mail = MESSAGE_STRUCT.new
     mail.from_display_name = parsed_incoming_mail[:from_display_name]
     mail.subject = parsed_incoming_mail[:subject]
     mail.msg_size = format('%<MB>.2f', MB: raw_incoming_mail.size.to_f / 1024 / 1024)

+ 3 - 1
app/models/translation/synchronizes_from_po.rb

@@ -3,6 +3,8 @@
 module Translation::SynchronizesFromPo
   extend ActiveSupport::Concern
 
+  TRANSLATION_FILE_STRUCT = Struct.new(:translation, :translation_file, keyword_init: true).freeze
+
   class_methods do # rubocop:disable Metrics/BlockLength
 
     def sync
@@ -64,7 +66,7 @@ module Translation::SynchronizesFromPo
 
           # For 'en-*' locales, treat source as translation as well, to indicate that nothing is missing.
           translation = source if translation.empty? && locale.start_with?('en')
-          result[source] = OpenStruct.new(translation: translation, translation_file: file)
+          result[source] = TRANSLATION_FILE_STRUCT.new(translation: translation, translation_file: file)
         end
       end
       result

+ 1 - 1
spec/lib/notification_factory/mailer_spec.rb

@@ -11,7 +11,7 @@ RSpec.describe NotificationFactory::Mailer do
       let(:parsed_incoming_mail) { Channel::EmailParser.new.parse raw_incoming_mail }
 
       let(:incoming_mail) do
-        mail = OpenStruct.new
+        mail = Channel::EmailParser::MESSAGE_STRUCT.new
         mail.from_display_name = parsed_incoming_mail[:from_display_name]
         mail.subject = parsed_incoming_mail[:subject]
         mail.msg_size = format('%<MB>.2f', MB: raw_incoming_mail.size.to_f / 1024 / 1024)

+ 6 - 1
spec/models/ticket_spec.rb

@@ -438,11 +438,16 @@ RSpec.describe Ticket, type: :model do
     end
 
     describe '#perform_changes' do
+      before do
+        stub_const('PERFORMABLE_STRUCT', Struct.new(:id, :perform, keyword_init: true))
+      end
 
       # a `performable` can be a Trigger or a Job
       # we use DuckTyping and expect that a performable
       # implements the following interface
-      let(:performable) { OpenStruct.new(id: 1, perform: perform) }
+      let(:performable) do
+        PERFORMABLE_STRUCT.new(id: 1, perform: perform)
+      end
 
       # Regression test for https://github.com/zammad/zammad/issues/2001
       describe 'argument handling' do

+ 18 - 10
spec/models/translation/translation_synchronizes_from_po_spec.rb

@@ -48,21 +48,29 @@ RSpec.describe Translation do
 
     context 'when getting the en-us strings' do
       it 'contains the translation for "yes"' do
-        expect(described_class.strings_for_locale('en-us')).to include(
-          'yes'             => OpenStruct.new(translation: 'yes', translation_file: 'i18n/zammad.pot'),
-          'FORMAT_DATE'     => OpenStruct.new(translation: 'mm/dd/yyyy', translation_file: 'i18n/zammad.pot'),
-          'FORMAT_DATETIME' => OpenStruct.new(translation: 'mm/dd/yyyy HH:MM', translation_file: 'i18n/zammad.pot'),
-        )
+        expect(described_class.strings_for_locale('en-us')['yes']).to have_attributes(translation: 'yes', translation_file: 'i18n/zammad.pot')
+      end
+
+      it 'contains the translation for "FORMAT_DATE"' do
+        expect(described_class.strings_for_locale('en-us')['FORMAT_DATE']).to have_attributes(translation: 'mm/dd/yyyy', translation_file: 'i18n/zammad.pot')
+      end
+
+      it 'contains the translation for "FORMAT_DATE_TIME"' do
+        expect(described_class.strings_for_locale('en-us')['FORMAT_DATETIME']).to have_attributes(translation: 'mm/dd/yyyy HH:MM', translation_file: 'i18n/zammad.pot')
       end
     end
 
     context 'when getting the de-de strings' do
       it 'contains the translation for "yes"' do
-        expect(described_class.strings_for_locale('de-de')).to include(
-          'yes'             => OpenStruct.new(translation: 'ja', translation_file: 'i18n/zammad.de-de.po'),
-          'FORMAT_DATE'     => OpenStruct.new(translation: 'dd.mm.yyyy', translation_file: 'i18n/zammad.de-de.po'),
-          'FORMAT_DATETIME' => OpenStruct.new(translation: 'dd.mm.yyyy HH:MM', translation_file: 'i18n/zammad.de-de.po'),
-        )
+        expect(described_class.strings_for_locale('de-de')['yes']).to have_attributes(translation: 'ja', translation_file: 'i18n/zammad.de-de.po')
+      end
+
+      it 'contains the translation for "FORMAT_DATE"' do
+        expect(described_class.strings_for_locale('de-de')['FORMAT_DATE']).to have_attributes(translation: 'dd.mm.yyyy', translation_file: 'i18n/zammad.de-de.po')
+      end
+
+      it 'contains the translation for "FORMAT_DATE_TIME"' do
+        expect(described_class.strings_for_locale('de-de')['FORMAT_DATETIME']).to have_attributes(translation: 'dd.mm.yyyy HH:MM', translation_file: 'i18n/zammad.de-de.po')
       end
     end
   end