aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands/credentials_test.rb
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-09-12 17:06:59 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-09-14 07:17:25 +0900
commitd5d41c82810f96ee7ab5a34aeb75b46fe407a596 (patch)
tree18911afc18ef5c8fdf7407f5767a0905bde28d13 /railties/test/commands/credentials_test.rb
parent69f976b859cae7f9d050152103da018b7f5dda6d (diff)
downloadrails-d5d41c82810f96ee7ab5a34aeb75b46fe407a596.tar.gz
rails-d5d41c82810f96ee7ab5a34aeb75b46fe407a596.tar.bz2
rails-d5d41c82810f96ee7ab5a34aeb75b46fe407a596.zip
Make master key added to gitignore the same value as when creating appplication
For gitignore generated by `rails new`, key with a leading slash is specified. https://github.com/rails/rails/blob/69f976b859cae7f9d050152103da018b7f5dda6d/railties/lib/rails/generators/rails/app/templates/gitignore#L11 Therefore, when executing `credentials:edit`, also need leading slack. In order to avoid such a difference, fixed to use same method for `rails new` and `credentials:edit`.
Diffstat (limited to 'railties/test/commands/credentials_test.rb')
-rw-r--r--railties/test/commands/credentials_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/commands/credentials_test.rb b/railties/test/commands/credentials_test.rb
new file mode 100644
index 0000000000..fe52c306d2
--- /dev/null
+++ b/railties/test/commands/credentials_test.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require "isolation/abstract_unit"
+require "env_helpers"
+require "rails/command"
+require "rails/commands/credentials/credentials_command"
+
+class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
+ include ActiveSupport::Testing::Isolation, EnvHelpers
+
+ setup { build_app }
+
+ teardown { teardown_app }
+
+ test "edit command does not add master key to gitignore when already exist" do
+ run_edit_command
+
+ Dir.chdir(app_path) do
+ gitignore = File.read(".gitignore")
+ assert_equal 1, gitignore.scan(%r|config/master\.key|).length
+ end
+ end
+
+ private
+ def run_edit_command(editor: "cat")
+ switch_env("EDITOR", editor) do
+ rails "credentials:edit"
+ end
+ end
+end