diff --git a/lib/rails/convert_rails_logger.rb b/lib/rails/convert_rails_logger.rb index 3625394d..9ef27594 100644 --- a/lib/rails/convert_rails_logger.rb +++ b/lib/rails/convert_rails_logger.rb @@ -2,17 +2,17 @@ Synvert::Rewriter.new 'rails', 'convert_rails_logger' do description <<~EOS - It converts RAILS_DEFAULT_LOGGER to Rails.logger. + It converts RAILS_DEFAULT_LOGGER to Rails.logger. - ```ruby - RAILS_DEFAULT_LOGGER - ``` + ```ruby + RAILS_DEFAULT_LOGGER + ``` - => + => - ```ruby - Rails.logger - ``` + ```ruby + Rails.logger + ``` EOS if_gem 'rails', { gte: '2.3.0' } diff --git a/spec/rails/add_application_job_spec.rb b/spec/rails/add_application_job_spec.rb index b891d6c9..94f6a4ff 100644 --- a/spec/rails/add_application_job_spec.rb +++ b/spec/rails/add_application_job_spec.rb @@ -9,8 +9,8 @@ let(:fake_file_path) { 'app/jobs/application_job.rb' } let(:test_content) { nil } let(:test_rewritten_content) { <<~EOS } - class ApplicationJob < ActiveJob::Base - end + class ApplicationJob < ActiveJob::Base + end EOS include_examples 'convertable' @@ -19,13 +19,13 @@ class ApplicationJob < ActiveJob::Base context 'rename ActiveJob::Base' do let(:fake_file_path) { 'app/jobs/post_job.rb' } let(:test_content) { <<~EOS } - class PostJob < ActiveJob::Base - end + class PostJob < ActiveJob::Base + end EOS let(:test_rewritten_content) { <<~EOS } - class PostJob < ApplicationJob - end + class PostJob < ApplicationJob + end EOS include_examples 'convertable' diff --git a/spec/rails/add_application_record_spec.rb b/spec/rails/add_application_record_spec.rb index 32a92dfb..1887044d 100644 --- a/spec/rails/add_application_record_spec.rb +++ b/spec/rails/add_application_record_spec.rb @@ -9,9 +9,9 @@ let(:fake_file_path) { 'app/models/application_record.rb' } let(:test_content) { nil } let(:test_rewritten_content) { <<~EOS } - class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true - end + class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true + end EOS include_examples 'convertable' @@ -20,13 +20,13 @@ class ApplicationRecord < ActiveRecord::Base context 'rename ActiveRecord::Base' do let(:fake_file_path) { 'app/models/post.rb' } let(:test_content) { <<~EOS } - class Post < ActiveRecord::Base - end + class Post < ActiveRecord::Base + end EOS let(:test_rewritten_content) { <<~EOS } - class Post < ApplicationRecord - end + class Post < ApplicationRecord + end EOS include_examples 'convertable' diff --git a/spec/rails/convert_active_record_dirty_5_0_to_5_1_spec.rb b/spec/rails/convert_active_record_dirty_5_0_to_5_1_spec.rb index 2dae297e..284deeee 100644 --- a/spec/rails/convert_active_record_dirty_5_0_to_5_1_spec.rb +++ b/spec/rails/convert_active_record_dirty_5_0_to_5_1_spec.rb @@ -6,70 +6,70 @@ let(:rewriter_name) { 'rails/convert_active_record_dirty_5_0_to_5_1' } let(:fake_file_path) { 'app/models/post.rb' } let(:schema_content) { <<~EOS } - ActiveRecord::Schema.define(version: 20140211112752) do - create_table "posts", force: true do |t| - t.string "title" - t.string "summary" - t.boolean "status" - t.timestamps - end + ActiveRecord::Schema.define(version: 20140211112752) do + create_table "posts", force: true do |t| + t.string "title" + t.string "summary" + t.boolean "status" + t.timestamps end + end EOS let(:test_content) { <<~EOS } - class Post < ActiveRecord::Base - before_create :call_before_create - before_update :call_before_update, unless: :title_changed? - before_save :call_before_save, if: -> { status_changed? || summary_changed? } - after_create :call_after_create - after_update :call_after_update, unless: :title_changed? - after_save :call_after_save, if: -> { status_changed? || summary_changed? } + class Post < ActiveRecord::Base + before_create :call_before_create + before_update :call_before_update, unless: :title_changed? + before_save :call_before_save, if: -> { status_changed? || summary_changed? } + after_create :call_after_create + after_update :call_after_update, unless: :title_changed? + after_save :call_after_save, if: -> { status_changed? || summary_changed? } - before_save do - if title_changed? - end + before_save do + if title_changed? end + end - def call_before_create - if title_changed? - changes - end + def call_before_create + if title_changed? + changes end + end - def call_after_create - if title_changed? - changes - end + def call_after_create + if title_changed? + changes end end + end EOS let(:test_rewritten_content) { <<~EOS } - class Post < ActiveRecord::Base - before_create :call_before_create - before_update :call_before_update, unless: :will_save_change_to_title? - before_save :call_before_save, if: -> { will_save_change_to_status? || will_save_change_to_summary? } - after_create :call_after_create - after_update :call_after_update, unless: :saved_change_to_title? - after_save :call_after_save, if: -> { saved_change_to_status? || saved_change_to_summary? } + class Post < ActiveRecord::Base + before_create :call_before_create + before_update :call_before_update, unless: :will_save_change_to_title? + before_save :call_before_save, if: -> { will_save_change_to_status? || will_save_change_to_summary? } + after_create :call_after_create + after_update :call_after_update, unless: :saved_change_to_title? + after_save :call_after_save, if: -> { saved_change_to_status? || saved_change_to_summary? } - before_save do - if will_save_change_to_title? - end + before_save do + if will_save_change_to_title? end + end - def call_before_create - if will_save_change_to_title? - changes_to_save - end + def call_before_create + if will_save_change_to_title? + changes_to_save end + end - def call_after_create - if saved_change_to_title? - saved_changes - end + def call_after_create + if saved_change_to_title? + saved_changes end end + end EOS before do diff --git a/spec/rails/convert_render_text_to_render_plain_spec.rb b/spec/rails/convert_render_text_to_render_plain_spec.rb index f941df96..0384a04c 100644 --- a/spec/rails/convert_render_text_to_render_plain_spec.rb +++ b/spec/rails/convert_render_text_to_render_plain_spec.rb @@ -6,27 +6,27 @@ let(:rewriter_name) { 'rails/convert_render_text_to_render_plain' } let(:fake_file_path) { 'app/controllers/posts_controller.rb' } let(:test_content) { <<~EOS } - class PostsController < ApplicationController - def foo - render text: 'OK' - end + class PostsController < ApplicationController + def foo + render text: 'OK' + end - def bar - render text: 'Not OK', status: 403 - end + def bar + render text: 'Not OK', status: 403 end + end EOS let(:test_rewritten_content) { <<~EOS } - class PostsController < ApplicationController - def foo - render plain: 'OK' - end + class PostsController < ApplicationController + def foo + render plain: 'OK' + end - def bar - render plain: 'Not OK', status: 403 - end + def bar + render plain: 'Not OK', status: 403 end + end EOS include_examples 'convertable' diff --git a/spec/rails/upgrade_3_0_to_3_1_spec.rb b/spec/rails/upgrade_3_0_to_3_1_spec.rb index ecb0d6fa..5de157e9 100644 --- a/spec/rails/upgrade_3_0_to_3_1_spec.rb +++ b/spec/rails/upgrade_3_0_to_3_1_spec.rb @@ -63,15 +63,15 @@ ' } let(:wrap_parameters_rewritten_content) { <<~EOS } - # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. - ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] - end + # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. + ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] + end - # Disable root element in JSON by default. - ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false - end + # Disable root element in JSON by default. + ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false + end EOS let(:session_store_content) { diff --git a/spec/ruby/new_2_2_hash_syntax_spec.rb b/spec/ruby/new_2_2_hash_syntax_spec.rb index d1e82aa6..5a39aa48 100644 --- a/spec/ruby/new_2_2_hash_syntax_spec.rb +++ b/spec/ruby/new_2_2_hash_syntax_spec.rb @@ -5,19 +5,19 @@ RSpec.describe 'Uses ruby 2.2 new hash synax' do let(:rewriter_name) { 'ruby/new_2_2_hash_syntax' } let(:test_content) { <<~'EOS' } - { :foo => 'bar', 'foo' => 'bar' } - { :key1 => 'value1', :key2 => 'value2' } - { foo_key: 'foo_value', bar_key: 42, "baz-key" => true } - { :"foo-#{key}" => 'foo_value', :"bar-key" => 42, :"a\tb" => false, :"c'd" => nil } - { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } + { :foo => 'bar', 'foo' => 'bar' } + { :key1 => 'value1', :key2 => 'value2' } + { foo_key: 'foo_value', bar_key: 42, "baz-key" => true } + { :"foo-#{key}" => 'foo_value', :"bar-key" => 42, :"a\tb" => false, :"c'd" => nil } + { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } EOS let(:test_rewritten_content) { <<~'EOS' } - { foo: 'bar', 'foo' => 'bar' } - { key1: 'value1', key2: 'value2' } - { foo_key: 'foo_value', bar_key: 42, "baz-key" => true } - { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } - { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } + { foo: 'bar', 'foo' => 'bar' } + { key1: 'value1', key2: 'value2' } + { foo_key: 'foo_value', bar_key: 42, "baz-key" => true } + { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } + { "foo-#{key}": 'foo_value', 'bar-key': 42, "a\tb": false, "c'd": nil } EOS before do