Skip to content

Commit e20589c

Browse files
committed
Remove deprecated environment argument from the rails commands
1 parent 9d39f81 commit e20589c

5 files changed

Lines changed: 10 additions & 55 deletions

File tree

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `environment` argument from the rails commands.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `capify!`.
26

37
*Rafael Mendonça França*

railties/lib/rails/command/environment_argument.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@ module EnvironmentArgument #:nodoc:
88
extend ActiveSupport::Concern
99

1010
included do
11-
argument :environment, optional: true, banner: "environment"
12-
1311
class_option :environment, aliases: "-e", type: :string,
1412
desc: "Specifies the environment to run this console under (test/development/production)."
1513
end
1614

1715
private
1816
def extract_environment_option_from_argument
19-
if environment
20-
self.options = options.merge(environment: acceptable_environment(environment))
21-
22-
ActiveSupport::Deprecation.warn "Passing the environment's name as a " \
23-
"regular argument is deprecated and " \
24-
"will be removed in the next Rails " \
25-
"version. Please, use the -e option " \
26-
"instead."
27-
elsif options[:environment]
17+
if options[:environment]
2818
self.options = options.merge(environment: acceptable_environment(options[:environment]))
2919
else
3020
self.options = options.merge(environment: Rails::Command.environment)

railties/test/application/console_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_sandbox
149149
end
150150

151151
def test_environment_option_and_irb_option
152-
spawn_console("test -- --verbose")
152+
spawn_console("-e test -- --verbose")
153153

154154
write_prompt "a = 1", "a = 1"
155155
write_prompt "puts Rails.env", "puts Rails.env\r\ntest"

railties/test/commands/console_test.rb

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,7 @@ def test_environment_option
9494
assert_match(/\sspecial-production\s/, output)
9595
end
9696

97-
def test_rails_env_is_production_when_first_argument_is_p
98-
assert_deprecated do
99-
start ["p"]
100-
assert_match(/\sproduction\s/, output)
101-
end
102-
end
103-
104-
def test_rails_env_is_test_when_first_argument_is_t
105-
assert_deprecated do
106-
start ["t"]
107-
assert_match(/\stest\s/, output)
108-
end
109-
end
110-
111-
def test_rails_env_is_development_when_argument_is_d
112-
assert_deprecated do
113-
start ["d"]
114-
assert_match(/\sdevelopment\s/, output)
115-
end
116-
end
117-
118-
def test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present
97+
def test_rails_env_is_dev_when_environment_option_is_dev_and_dev_env_is_present
11998
Rails::Command::ConsoleCommand.class_eval do
12099
alias_method :old_environments, :available_environments
121100

@@ -124,9 +103,7 @@ def test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present
124103
end
125104
end
126105

127-
assert_deprecated do
128-
assert_match("dev", parse_arguments(["dev"])[:environment])
129-
end
106+
assert_match("dev", parse_arguments(["-e", "dev"])[:environment])
130107
ensure
131108
Rails::Command::ConsoleCommand.class_eval do
132109
undef_method :available_environments

railties/test/commands/dbconsole_test.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,12 @@ def test_env
9999
ENV["RACK_ENV"] = nil
100100
end
101101

102-
def test_rails_env_is_development_when_argument_is_dev
103-
assert_deprecated do
104-
stub_available_environments([ "development", "test" ]) do
105-
assert_match("development", parse_arguments([ "dev" ])[:environment])
106-
end
107-
end
108-
end
109-
110102
def test_rails_env_is_development_when_environment_option_is_dev
111103
stub_available_environments([ "development", "test" ]) do
112104
assert_match("development", parse_arguments([ "-e", "dev" ])[:environment])
113105
end
114106
end
115107

116-
def test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present
117-
assert_deprecated do
118-
stub_available_environments([ "dev" ]) do
119-
assert_match("dev", parse_arguments([ "dev" ])[:environment])
120-
end
121-
end
122-
end
123-
124108
def test_mysql
125109
start(adapter: "mysql2", database: "db")
126110
assert_not aborted
@@ -265,14 +249,14 @@ def test_print_help_short
265249
stdout = capture(:stdout) do
266250
Rails::Command.invoke(:dbconsole, ["-h"])
267251
end
268-
assert_match(/rails dbconsole \[environment\]/, stdout)
252+
assert_match(/rails dbconsole \[options\]/, stdout)
269253
end
270254

271255
def test_print_help_long
272256
stdout = capture(:stdout) do
273257
Rails::Command.invoke(:dbconsole, ["--help"])
274258
end
275-
assert_match(/rails dbconsole \[environment\]/, stdout)
259+
assert_match(/rails dbconsole \[options\]/, stdout)
276260
end
277261

278262
attr_reader :aborted, :output

0 commit comments

Comments
 (0)