File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
lib/rails/commands/credentials Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,11 @@ def relative_path(path)
128
128
end
129
129
130
130
def extract_environment_from_path ( path )
131
- available_environments . find { |env | path . end_with? ( "#{ env } .yml.enc" ) }
131
+ available_environments . find { |env | path . end_with? ( "#{ env } .yml.enc" ) } || extract_custom_environment ( path )
132
+ end
133
+
134
+ def extract_custom_environment ( path )
135
+ path =~ %r{config/credentials/(.+)\. yml\. enc} && $1
132
136
end
133
137
end
134
138
end
Original file line number Diff line number Diff line change @@ -285,6 +285,20 @@ class Rails::Command::CredentialsTest < ActiveSupport::TestCase
285
285
assert_match ( raw_content , run_diff_command ( "config/credentials.yml.enc" ) )
286
286
end
287
287
288
+ test "diff for custom environment" do
289
+ run_edit_command ( environment : "custom" )
290
+
291
+ assert_match ( /access_key_id: 123/ , run_diff_command ( "config/credentials/custom.yml.enc" ) )
292
+ end
293
+
294
+ test "diff for custom environment when key is not available" do
295
+ run_edit_command ( environment : "custom" )
296
+ remove_file "config/credentials/custom.key"
297
+
298
+ raw_content = File . read ( app_path ( "config" , "credentials" , "custom.yml.enc" ) )
299
+ assert_match ( raw_content , run_diff_command ( "config/credentials/custom.yml.enc" ) )
300
+ end
301
+
288
302
test "diff returns raw encrypted content when errors occur" do
289
303
run_edit_command ( environment : "development" )
290
304
You can’t perform that action at this time.
0 commit comments