Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise the "XML is not HTML" test #27414

Merged
merged 1 commit into from
Dec 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions actionpack/test/controller/test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def test_html_output
end

def test_xml_output
response.content_type = "application/xml"
response.content_type = params[:response_as]
render plain: <<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<area>area is an empty tag in HTML, raising an error if not in xml mode</area>
<area><p>area is an empty tag in HTML, so it won't contain this content</p></area>
</root>
XML
end
Expand Down Expand Up @@ -374,18 +374,18 @@ def test_multiple_calls
assert_equal "OK", @response.body
end

def test_should_not_impose_childless_html_tags_in_xml
process :test_xml_output
def test_should_impose_childless_html_tags_in_html
process :test_xml_output, params: { response_as: "text/html" }

begin
$stderr = StringIO.new
assert_select "area" #This will cause a warning if content is processed as HTML
$stderr.rewind && err = $stderr.read
ensure
$stderr = STDERR
end
# <area> auto-closes, so the <p> becomes a sibling
assert_select "root > area + p"
end

def test_should_not_impose_childless_html_tags_in_xml
process :test_xml_output, params: { response_as: "application/xml" }

assert err.empty?, err.inspect
# <area> is not special, so the <p> is its child
assert_select "root > area > p"
end

def test_assert_generates
Expand Down