Skip to content

Commit a70d89c

Browse files
committed
Merge pull request rails#51766 from Shopify/revert-actionable-errors-retry
Revert "Merge pull request rails#50941 from andrewn617/actionable-cli"
1 parent a4d58dd commit a70d89c

File tree

4 files changed

+7
-64
lines changed

4 files changed

+7
-64
lines changed

railties/lib/rails/command/base.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,26 +179,6 @@ def invoke_command(command, *) # :nodoc:
179179
ensure
180180
@current_subcommand = original_subcommand
181181
end
182-
183-
protected
184-
def with_actionable_errors_retried(&block)
185-
block.call
186-
rescue ActiveSupport::ActionableError => e
187-
puts e.to_s.strip
188-
exit 1 unless tty?
189-
190-
ActiveSupport::ActionableError.actions(e).each_key do |action_name|
191-
if yes? "#{action_name}? [Yn]"
192-
ActiveSupport::ActionableError.dispatch(e, action_name)
193-
return with_actionable_errors_retried(&block)
194-
end
195-
end
196-
exit 1
197-
end
198-
199-
def tty?
200-
STDOUT.tty?
201-
end
202182
end
203183
end
204184
end

railties/lib/rails/commands/test/test_command.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def perform(*args)
3030

3131
Rails::TestUnit::Runner.parse_options(args)
3232
run_prepare_task if self.args.none?(EXACT_TEST_ARGUMENT_PATTERN)
33-
with_actionable_errors_retried do
34-
Rails::TestUnit::Runner.run(args)
35-
end
33+
Rails::TestUnit::Runner.run(args)
3634
rescue Rails::TestUnit::InvalidTestError => error
3735
say error.message
3836
end

railties/lib/rails/testing/maintain_test_schema.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# frozen_string_literal: true
22

33
if defined?(ActiveRecord::Base)
4-
5-
ActiveRecord::Migration.maintain_test_schema!
4+
begin
5+
ActiveRecord::Migration.maintain_test_schema!
6+
rescue ActiveRecord::PendingMigrationError => e
7+
puts e.to_s.strip
8+
exit 1
9+
end
610

711
if Rails.configuration.eager_load
812
ActiveRecord::Base.descendants.each do |model|

railties/test/application/test_test.rb

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -345,45 +345,6 @@ def self.load_schema!
345345
assert_unsuccessful_run "models/user_test.rb", "SCHEMA LOADED!"
346346
end
347347

348-
def test_actionable_command_line_error_with_tty
349-
rails "generate", "scaffold", "user", "name:string"
350-
app_file "config/initializers/thor_yes.rb", <<-RUBY
351-
Rails::Command::Base.class_eval <<-INITIALIZER
352-
def yes?(statement, color = nil)
353-
raise ArgumentError unless statement == "Run pending migrations? [Yn]"
354-
true
355-
end
356-
357-
def tty?
358-
true
359-
end
360-
INITIALIZER
361-
RUBY
362-
363-
run_test_file("models/user_test.rb").tap do |output|
364-
assert_match "Migrations are pending. To resolve this issue, run:", output
365-
assert_match "CreateUsers: migrating", output
366-
assert_match "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips", output
367-
end
368-
end
369-
370-
def test_actionable_command_line_without_tty
371-
rails "generate", "scaffold", "user", "name:string"
372-
app_file "config/initializers/thor_yes.rb", <<-RUBY
373-
Rails::Command::Base.class_eval <<-INITIALIZER
374-
def tty?
375-
false
376-
end
377-
INITIALIZER
378-
RUBY
379-
380-
run_test_file("models/user_test.rb").tap do |output|
381-
assert_match "Migrations are pending. To resolve this issue, run:", output
382-
assert_no_match "CreateUsers: migrating", output
383-
assert_no_match "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips", output
384-
end
385-
end
386-
387348
private
388349
def assert_unsuccessful_run(name, message)
389350
result = run_test_file(name)

0 commit comments

Comments
 (0)