File tree Expand file tree Collapse file tree 7 files changed +11
-75
lines changed Expand file tree Collapse file tree 7 files changed +11
-75
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ Please refer to the [Changelog][railties] for detailed changes.
34
34
35
35
* Remove deprecated file ` rails/console/helpers ` .
36
36
37
+ * Remove deprecated support to extend Rails console through ` Rails::ConsoleMethods ` .
38
+
37
39
### Deprecations
38
40
39
41
### Notable changes
Original file line number Diff line number Diff line change
1
+ * Remove deprecated support to extend Rails console through ` Rails::ConsoleMethods ` .
2
+
3
+ * Rafael Mendonça França*
4
+
1
5
* Remove deprecated file ` rails/console/helpers ` .
2
6
3
7
* Rafael Mendonça França*
Original file line number Diff line number Diff line change 6
6
module Rails
7
7
class Console
8
8
class RailsHelperBase < IRB ::HelperMethod ::Base
9
- include ConsoleMethods
10
9
end
11
10
12
11
class ControllerHelper < RailsHelperBase
@@ -61,8 +60,6 @@ def execute
61
60
end
62
61
63
62
class ReloadCommand < IRB ::Command ::Base
64
- include ConsoleMethods
65
-
66
63
category "Rails console"
67
64
description "Reloads the Rails application."
68
65
@@ -120,10 +117,6 @@ def start
120
117
end
121
118
end
122
119
123
- # Because some users/libs use Rails::ConsoleMethods to extend Rails console,
124
- # we still include it for backward compatibility.
125
- IRB ::ExtendCommandBundle . include ConsoleMethods
126
-
127
120
# Respect user's choice of prompt mode.
128
121
IRB . conf [ :PROMPT_MODE ] = :RAILS_PROMPT if IRB . conf [ :PROMPT_MODE ] == :DEFAULT
129
122
IRB ::Irb . new . run ( IRB . conf )
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- module Rails
4
- module ConsoleMethods
5
- def self . include ( _mod , ...)
6
- raise_deprecation_warning
7
- super
8
- end
9
-
10
- def self . method_added ( _method_name )
11
- raise_deprecation_warning
12
- super
13
- end
14
-
15
- def self . raise_deprecation_warning
16
- Rails . deprecator . warn ( <<~MSG , caller_locations ( 2 ..2 ) )
17
- Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0.
18
- Please directly use IRB's extension API to add new commands or helpers to the console.
19
- For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
20
- MSG
21
- end
22
- end
23
- end
3
+ Rails . deprecator . warn ( <<~MSG , caller_locations ( 0 ..1 ) )
4
+ `rails/console/methods` has been deprecated and will be removed in Rails 8.1.
5
+ Please directly use IRB's extension API to add new commands or helpers to the console.
6
+ For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
7
+ MSG
Original file line number Diff line number Diff line change @@ -452,7 +452,6 @@ def initialize
452
452
# Load console and invoke the registered hooks.
453
453
# Check Rails::Railtie.console for more info.
454
454
def load_console ( app = self )
455
- require "rails/console/methods"
456
455
run_console_blocks ( app )
457
456
self
458
457
end
Original file line number Diff line number Diff line change @@ -200,51 +200,6 @@ def test_reload_command_fires_preparation_and_cleanup_callbacks
200
200
write_prompt "c" , "=> 3"
201
201
end
202
202
203
- def test_rails_console_methods_patch_backward_compatibility_with_module_inclusion
204
- add_to_config <<-RUBY
205
- module MyConsole
206
- def foo
207
- "this is foo"
208
- end
209
- end
210
-
211
- console do
212
- ::Rails::ConsoleMethods.include(MyConsole)
213
- end
214
- RUBY
215
-
216
- spawn_console ( "-e development" , wait_for_prompt : false )
217
-
218
- line_number = 0
219
- app = File . readlines ( "#{ app_path } /config/application.rb" )
220
- app . each_with_index do |line , index |
221
- if line . include? ( "Rails::ConsoleMethods.include(MyConsole)" )
222
- line_number = index + 1
223
- end
224
- end
225
-
226
- assert_output "Extending Rails console through `Rails::ConsoleMethods` is deprecated" , @primary , 30
227
- assert_output "(called from block in <class:Application> at #{ app_path } /config/application.rb:#{ line_number } )" , @primary , 30
228
- write_prompt "foo" , "=> \" this is foo\" "
229
- end
230
-
231
- def test_rails_console_methods_patch_backward_compatibility_with_module_reopening
232
- add_to_config <<-RUBY
233
- console do
234
- ::Rails::ConsoleMethods.module_eval do
235
- def foo
236
- "this is foo"
237
- end
238
- end
239
- end
240
- RUBY
241
-
242
- spawn_console ( "-e development" , wait_for_prompt : false )
243
-
244
- assert_output "Extending Rails console through `Rails::ConsoleMethods` is deprecated" , @primary , 30
245
- write_prompt "foo" , "=> \" this is foo\" "
246
- end
247
-
248
203
def test_reload_command_reload_constants
249
204
app_file "app/models/user.rb" , <<-MODEL
250
205
class User
Original file line number Diff line number Diff line change @@ -167,7 +167,6 @@ def config
167
167
end
168
168
169
169
def load_console
170
- require "rails/console/methods"
171
170
end
172
171
end
173
172
mocked_app . new ( console )
You can’t perform that action at this time.
0 commit comments