mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Compare content_type with Mime::XML instead of regexp
Regexp is broken for both content types including charsets and for integration tests, where the content_type is a Mime::Type and not String
This commit is contained in:
parent
a5a4b56029
commit
4be3997c9f
2 changed files with 18 additions and 1 deletions
|
@ -12,7 +12,7 @@ module ActionDispatch
|
|||
include Rails::Dom::Testing::Assertions
|
||||
|
||||
def html_document
|
||||
@html_document ||= if @response.content_type =~ /xml$/
|
||||
@html_document ||= if @response.content_type === Mime::XML
|
||||
Nokogiri::XML::Document.parse(@response.body)
|
||||
else
|
||||
Nokogiri::HTML::Document.parse(@response.body)
|
||||
|
|
|
@ -363,6 +363,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
|
|||
respond_to do |format|
|
||||
format.html { render :text => "OK", :status => 200 }
|
||||
format.js { render :text => "JS OK", :status => 200 }
|
||||
format.xml { render :xml => "<root></root>", :status => 200 }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -419,6 +420,22 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_get_xml
|
||||
with_test_route_set do
|
||||
get "/get", {}, {"HTTP_ACCEPT" => "application/xml"}
|
||||
assert_equal 200, status
|
||||
assert_equal "OK", status_message
|
||||
assert_response 200
|
||||
assert_response :success
|
||||
assert_response :ok
|
||||
assert_equal({}, cookies.to_hash)
|
||||
assert_equal "<root></root>", body
|
||||
assert_equal "<root></root>", response.body
|
||||
assert_instance_of Nokogiri::XML::Document, html_document
|
||||
assert_equal 1, request_count
|
||||
end
|
||||
end
|
||||
|
||||
def test_post
|
||||
with_test_route_set do
|
||||
post '/post'
|
||||
|
|
Loading…
Reference in a new issue