Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Commit

Permalink
Prefer ActionDispatch::Response#media_type when it's available
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
georgeclaghorn committed Jun 14, 2019
1 parent 2f42a3e commit 8da1f63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/turbolinks/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 8da1f63

Please sign in to comment.