From 8da1f63325e631e20fbff9033701fcc515e47fe0 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Fri, 14 Jun 2019 12:01:00 -0400 Subject: [PATCH] Prefer ActionDispatch::Response#media_type when it's available rails/rails@ea5f509 changed #content_type to return the unmodified Content-Type header, including all parameters. It also introduced #media_type, which behaves as #content_type did previously. Preferring #media_type fixes redirection assertions on edge Rails. --- lib/turbolinks/assertions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/turbolinks/assertions.rb b/lib/turbolinks/assertions.rb index 0a943be..383fc31 100644 --- a/lib/turbolinks/assertions.rb +++ b/lib/turbolinks/assertions.rb @@ -12,7 +12,7 @@ def assert_redirected_to(options = {}, message = nil) def assert_turbolinks_visited(options = {}, message = nil) assert_response(:ok, message) - assert_equal("text/javascript", response.content_type) + assert_equal("text/javascript", response.try(:media_type) || response.content_type) visit_location, _ = turbolinks_visit_location_and_action @@ -34,7 +34,7 @@ def assert_turbolinks_visited(options = {}, message = nil) # header is cleared after controller action processing to prevent it # from leaking into subsequent requests. def turbolinks_request? - !request.get? && response.content_type == "text/javascript" + !request.get? && (response.try(:media_type) || response.content_type) == "text/javascript" end def turbolinks_visit_location_and_action