File tree Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require "shellwords"
3
4
require "active_support/encrypted_file"
4
5
5
6
module Rails
@@ -22,6 +23,10 @@ def ensure_editor_available(command:)
22
23
end
23
24
end
24
25
26
+ def system_editor ( file_path )
27
+ system ( *Shellwords . split ( ENV [ "EDITOR" ] ) , file_path . to_s )
28
+ end
29
+
25
30
def catch_editing_exceptions
26
31
yield
27
32
rescue Interrupt
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require "pathname"
4
- require "shellwords"
5
4
require "active_support"
6
5
require "rails/command/helpers/editor"
7
6
require "rails/command/environment_argument"
@@ -93,10 +92,7 @@ def ensure_credentials_have_been_added
93
92
94
93
def change_credentials_in_system_editor
95
94
catch_editing_exceptions do
96
- credentials . change do |tmp_path |
97
- system ( *Shellwords . split ( ENV [ "EDITOR" ] ) , tmp_path . to_s )
98
- end
99
-
95
+ credentials . change { |tmp_path | system_editor ( tmp_path ) }
100
96
say "File encrypted and saved."
101
97
warn_if_credentials_are_invalid
102
98
end
Original file line number Diff line number Diff line change @@ -61,10 +61,7 @@ def ensure_encrypted_configuration_has_been_added
61
61
62
62
def change_encrypted_configuration_in_system_editor
63
63
catch_editing_exceptions do
64
- encrypted_configuration . change do |tmp_path |
65
- system ( "#{ ENV [ "EDITOR" ] } #{ tmp_path } " )
66
- end
67
-
64
+ encrypted_configuration . change { |tmp_path | system_editor ( tmp_path ) }
68
65
say "File encrypted and saved."
69
66
warn_if_encrypted_configuration_is_invalid
70
67
end
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ class Rails::Command::EncryptedCommandTest < ActiveSupport::TestCase
85
85
test "edit command does not display save confirmation message if interrupted" do
86
86
assert_match %r/file encrypted and saved/i , run_edit_command
87
87
88
- interrupt_command_process = %(exec ruby -e "Process.kill 'INT', Process.ppid")
88
+ interrupt_command_process = %(ruby -e "Process.kill 'INT', Process.ppid")
89
89
output = run_edit_command ( editor : interrupt_command_process )
90
90
91
91
assert_no_match %r/file encrypted and saved/i , output
You can’t perform that action at this time.
0 commit comments