From b75357878f9c12b1c32ca1ff62b72590d45f7d1b Mon Sep 17 00:00:00 2001 From: Steven Harman Date: Mon, 13 May 2024 14:21:54 -0400 Subject: [PATCH] =?UTF-8?q?Appease=20Rubocop=20=F0=9F=91=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_todo.yml | 1 + Gemfile | 7 +++++++ app/controllers/letter_opener_web/letters_controller.rb | 4 ++-- letter_opener_web.gemspec | 8 +------- lib/letter_opener_web/delivery_method.rb | 2 +- spec/dummy/config/environments/production.rb | 2 +- spec/models/letter_opener_web/letter_spec.rb | 8 +++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 856ab10..32c87ac 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,6 +13,7 @@ Style/Documentation: - 'spec/**/*' - 'test/**/*' - 'app/controllers/letter_opener_web/letters_controller.rb' + - 'app/controllers/letter_opener_web/application_controller.rb' - 'app/models/letter_opener_web/letter.rb' - 'lib/letter_opener_web.rb' - 'lib/letter_opener_web/delivery_method.rb' diff --git a/Gemfile b/Gemfile index 01ebedf..569cb7f 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,10 @@ gemspec group :test do gem 'codecov', require: false end + +gem 'rails', '~> 6.1' +gem 'rspec-rails', '~> 5.0' +gem 'rubocop', '~> 1.22' +gem 'rubocop-rails', '~> 2.12' +gem 'rubocop-rspec', '~> 2.5' +gem 'shoulda-matchers', '~> 5.0' diff --git a/app/controllers/letter_opener_web/letters_controller.rb b/app/controllers/letter_opener_web/letters_controller.rb index 7eaebd6..7fa6ff3 100644 --- a/app/controllers/letter_opener_web/letters_controller.rb +++ b/app/controllers/letter_opener_web/letters_controller.rb @@ -15,8 +15,8 @@ def index def show text = @letter.send("#{params[:style]}_text") - .gsub(/"plain\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'plain')}\"") - .gsub(/"rich\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'rich')}\"") + .gsub('"plain.html"', "\"#{routes.letter_path(id: @letter.id, style: 'plain')}\"") + .gsub('"rich.html"', "\"#{routes.letter_path(id: @letter.id, style: 'rich')}\"") render html: text.html_safe end diff --git a/letter_opener_web.gemspec b/letter_opener_web.gemspec index 339f3e7..a6386f2 100644 --- a/letter_opener_web.gemspec +++ b/letter_opener_web.gemspec @@ -17,7 +17,6 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) gem.executables = gem.files.grep(%r{^exe/}).map { |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ['lib'] gem.add_dependency 'actionmailer', '>= 5.2' @@ -25,10 +24,5 @@ Gem::Specification.new do |gem| gem.add_dependency 'railties', '>= 5.2' gem.add_dependency 'rexml' - gem.add_development_dependency 'rails', '~> 6.1' - gem.add_development_dependency 'rspec-rails', '~> 5.0' - gem.add_development_dependency 'rubocop', '~> 1.22' - gem.add_development_dependency 'rubocop-rails', '~> 2.12' - gem.add_development_dependency 'rubocop-rspec', '~> 2.5' - gem.add_development_dependency 'shoulda-matchers', '~> 5.0' + gem.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/letter_opener_web/delivery_method.rb b/lib/letter_opener_web/delivery_method.rb index d8a95b3..77e8eb8 100644 --- a/lib/letter_opener_web/delivery_method.rb +++ b/lib/letter_opener_web/delivery_method.rb @@ -5,7 +5,7 @@ module LetterOpenerWeb class DeliveryMethod < LetterOpener::DeliveryMethod def deliver!(mail) - original = ENV['LAUNCHY_DRY_RUN'] + original = ENV.fetch('LAUNCHY_DRY_RUN', nil) ENV['LAUNCHY_DRY_RUN'] = 'true' super diff --git a/spec/dummy/config/environments/production.rb b/spec/dummy/config/environments/production.rb index c6ef419..df4388c 100644 --- a/spec/dummy/config/environments/production.rb +++ b/spec/dummy/config/environments/production.rb @@ -84,7 +84,7 @@ config.active_support.disallowed_deprecation_warnings = [] # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" diff --git a/spec/models/letter_opener_web/letter_spec.rb b/spec/models/letter_opener_web/letter_spec.rb index 1e1245c..a73bcfe 100644 --- a/spec/models/letter_opener_web/letter_spec.rb +++ b/spec/models/letter_opener_web/letter_spec.rb @@ -33,12 +33,10 @@ def rich_text(mail_id) %w[1111_1111 2222_2222].each do |folder| FileUtils.mkdir_p("#{location}/#{folder}") - File.open("#{location}/#{folder}/plain.html", 'w') { |f| f.write("Plain text for #{folder}") } - File.open("#{location}/#{folder}/rich.html", 'w') { |f| f.write(rich_text(folder)) } + File.write("#{location}/#{folder}/plain.html", "Plain text for #{folder}") + File.write("#{location}/#{folder}/rich.html", rich_text(folder)) FileUtils.mkdir_p("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}") - File.open("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}/rich.html", 'w') do |f| - f.write("Rich text for #{folder}") - end + File.write("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}/rich.html", "Rich text for #{folder}") end end