Skip to content

Commit ca962ab

Browse files
authored
Merge pull request rails#53083 from jeromedalbert/fix-bcrypt-auth-generator
Fix bcrypt gem not added by auth generator
2 parents 4f376d6 + c939fe0 commit ca962ab

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
@@ -55,6 +55,16 @@ def test_authentication_generator
5555
end
5656
end
5757

58+
def test_authentication_generator_without_bcrypt_in_gemfile
59+
File.write("Gemfile", File.read("Gemfile").sub(/# gem "bcrypt".*\n/, ""))
60+
61+
run_generator
62+
63+
assert_file "Gemfile" do |content|
64+
assert_match(/\ngem "bcrypt"/, content)
65+
end
66+
end
67+
5868
def test_authentication_generator_with_api_flag
5969
run_generator(["--api"])
6070

0 commit comments

Comments
 (0)