aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md6
-rw-r--r--actionpack/lib/action_controller/metal/redirecting.rb3
-rw-r--r--actionpack/lib/action_dispatch/system_testing/server.rb2
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb6
-rw-r--r--actionpack/test/dispatch/system_testing/screenshot_helper_test.rb25
5 files changed, 34 insertions, 8 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 96f91b90ff..6bb1c63610 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,9 +1,3 @@
-* Silence Puma start-up messages running system tests.
-
- Fixes #28109.
-
- *Yuji Yaginuma* (#28283)
-
* Commit flash changes when using a redirect route.
Fixes #27992.
diff --git a/actionpack/lib/action_controller/metal/redirecting.rb b/actionpack/lib/action_controller/metal/redirecting.rb
index a349841082..a3159c29dd 100644
--- a/actionpack/lib/action_controller/metal/redirecting.rb
+++ b/actionpack/lib/action_controller/metal/redirecting.rb
@@ -50,6 +50,9 @@ module ActionController
# redirect_to post_url(@post), status: 301, flash: { updated_post_id: @post.id }
# redirect_to({ action: 'atom' }, alert: "Something serious happened")
#
+ # Statements after redirect_to in our controller get executed, so redirect_to doesn't stop the execution of the function.
+ 
# To terminate the execution of the function immediately after the redirect_to, use return.
+ # redirect_to post_url(@post) and return
def redirect_to(options = {}, response_status = {})
raise ActionControllerError.new("Cannot redirect to nil!") unless options
raise AbstractController::DoubleRenderError if response_body
diff --git a/actionpack/lib/action_dispatch/system_testing/server.rb b/actionpack/lib/action_dispatch/system_testing/server.rb
index ee4b7efce0..4a214ef713 100644
--- a/actionpack/lib/action_dispatch/system_testing/server.rb
+++ b/actionpack/lib/action_dispatch/system_testing/server.rb
@@ -11,7 +11,7 @@ module ActionDispatch
private
def register
Capybara.register_server :rails_puma do |app, port, host|
- Rack::Handler::Puma.run(app, Port: port, Threads: "0:1", Silent: true)
+ Rack::Handler::Puma.run(app, Port: port, Threads: "0:1")
end
end
diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
index ddc961cf84..e37f6d02aa 100644
--- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
+++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
@@ -22,7 +22,7 @@ module ActionDispatch
# fails add +take_failed_screenshot+ to the teardown block before clearing
# sessions.
def take_failed_screenshot
- take_screenshot if failed?
+ take_screenshot if failed? && supports_screenshot?
end
private
@@ -55,6 +55,10 @@ module ActionDispatch
def failed?
!passed? && !skipped?
end
+
+ def supports_screenshot?
+ page.driver.public_methods(false).include?(:save_screenshot)
+ end
end
end
end
diff --git a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
index 3b4ea96c4f..d6b501b3ac 100644
--- a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
+++ b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
@@ -1,5 +1,6 @@
require "abstract_unit"
require "action_dispatch/system_testing/test_helpers/screenshot_helper"
+require "capybara/dsl"
class ScreenshotHelperTest < ActiveSupport::TestCase
test "image path is saved in tmp directory" do
@@ -25,4 +26,28 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
end
end
end
+
+ test "rack_test driver does not support screenshot" do
+ begin
+ original_driver = Capybara.current_driver
+ Capybara.current_driver = :rack_test
+
+ new_test = ActionDispatch::SystemTestCase.new("x")
+ assert_not new_test.send(:supports_screenshot?)
+ ensure
+ Capybara.current_driver = original_driver
+ end
+ end
+
+ test "selenium driver supports screenshot" do
+ begin
+ original_driver = Capybara.current_driver
+ Capybara.current_driver = :selenium
+
+ new_test = ActionDispatch::SystemTestCase.new("x")
+ assert new_test.send(:supports_screenshot?)
+ ensure
+ Capybara.current_driver = original_driver
+ end
+ end
end