Skip to content

Commit c939fe0

Browse files
committed
Fix bcrypt gem not added by auth generator
--quiet is not a valid option for `bundle add`, so use Thor’s `capture: true` option instead.
1 parent 13d5f87 commit c939fe0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

railties/lib/rails/generators/rails/authentication/authentication_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def enable_bcrypt
4141
uncomment_lines "Gemfile", /gem "bcrypt"/
4242
Bundler.with_original_env { execute_command :bundle, "install --quiet" }
4343
else
44-
Bundler.with_original_env { execute_command :bundle, "add bcrypt --quiet" }
44+
Bundler.with_original_env { execute_command :bundle, "add bcrypt", capture: true }
4545
end
4646
end
4747

railties/test/generators/authentication_generator_test.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def setup
1212
Rails.application.config.root = Pathname(destination_root)
1313

1414
self.class.tests Rails::Generators::AppGenerator
15-
run_generator([destination_root])
15+
run_generator([destination_root, "--no-skip-bundle"])
1616

1717
self.class.tests Rails::Generators::AuthenticationGenerator
1818
end
@@ -52,6 +52,16 @@ def test_authentication_generator
5252
end
5353
end
5454

55+
def test_authentication_generator_without_bcrypt_in_gemfile
56+
File.write("Gemfile", File.read("Gemfile").sub(/# gem "bcrypt".*\n/, ""))
57+
58+
run_generator
59+
60+
assert_file "Gemfile" do |content|
61+
assert_match(/\ngem "bcrypt"/, content)
62+
end
63+
end
64+
5565
def test_authentication_generator_with_api_flag
5666
run_generator(["--api"])
5767

0 commit comments

Comments
 (0)