Skip to content

Commit b3e7adc

Browse files
committed
Don't add bin/rubocop if rubocop is not in Gemfile
1 parent 0d99610 commit b3e7adc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

railties/lib/rails/commands/app/update_command.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def generator_options
6969
skip_action_mailbox: !defined?(ActionMailbox::Engine),
7070
skip_action_text: !defined?(ActionText::Engine),
7171
skip_action_cable: !defined?(ActionCable::Engine),
72-
skip_brakeman: skip_brakeman?,
72+
skip_brakeman: skip_gem?("brakeman"),
73+
skip_rubocop: skip_gem?("rubocop"),
7374
skip_test: !defined?(Rails::TestUnitRailtie),
7475
skip_system_test: Rails.application.config.generators.system_tests.nil?,
7576
asset_pipeline: asset_pipeline,
@@ -89,8 +90,8 @@ def asset_pipeline
8990
end
9091
end
9192

92-
def skip_brakeman?
93-
require "brakeman"
93+
def skip_gem?(gem_name)
94+
gem gem_name
9495
false
9596
rescue LoadError
9697
true

railties/test/generators/app_generator_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ def test_app_update_preserves_skip_brakeman
296296
end
297297
end
298298

299+
def test_app_update_preserves_skip_rubocop
300+
run_generator [ destination_root, "--skip-rubocop" ]
301+
302+
FileUtils.cd(destination_root) do
303+
assert_no_changes -> { File.exist?("bin/rubocop") } do
304+
run_app_update
305+
end
306+
end
307+
end
308+
299309
def test_app_update_preserves_skip_test
300310
run_generator [ destination_root, "--skip-test" ]
301311

0 commit comments

Comments
 (0)