From a4229a534ff237443b445de9aec0310c0f388b56 Mon Sep 17 00:00:00 2001 From: Younes SERRAJ Date: Wed, 22 May 2019 10:21:59 +0200 Subject: Fix select_tag so that is doesn't change options when include_blank is set --- actionview/test/template/form_tag_helper_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 9ece9f3ad1..70c5ae6771 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -301,6 +301,13 @@ class FormTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end + def test_select_tag_with_include_blank_doesnt_change_options + options = { include_blank: true, prompt: "string" } + expected_options = options.dup + select_tag "places", raw(""), options + expected_options.each { |k, v| assert_equal v, options[k] } + end + def test_select_tag_with_include_blank_false actual = select_tag "places", raw(""), include_blank: false expected = %() -- cgit v1.2.3 From ea5f509643d6d9c468a9b26f6c45bd4e40fd67cf Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 17 Apr 2019 15:37:16 +0900 Subject: Change `ActionDispatch::Response#content_type` returning Content-Type header as it is MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ] --- .../test/actionpack/controller/render_test.rb | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index c8ce7366d1..9b1a720636 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -1003,14 +1003,14 @@ class RenderTest < ActionController::TestCase def test_render_xml get :render_xml_hello assert_equal "\n

Hello David

\n

This is grand!

\n\n", @response.body - assert_equal "application/xml", @response.content_type + assert_equal "application/xml", @response.media_type end # :ported: def test_render_xml_as_string_template get :render_xml_hello_as_string_template assert_equal "\n

Hello David

\n

This is grand!

\n\n", @response.body - assert_equal "application/xml", @response.content_type + assert_equal "application/xml", @response.media_type end # :ported: @@ -1039,7 +1039,7 @@ class RenderTest < ActionController::TestCase def test_rendered_format_without_format get :inline_rendered_format_without_format assert_equal "test", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_partials_list @@ -1077,7 +1077,7 @@ class RenderTest < ActionController::TestCase def test_accessing_local_assigns_in_inline_template get :accessing_local_assigns_in_inline_template, params: { local_name: "Local David" } assert_equal "Goodbye, Local David", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_should_implicitly_render_html_template_from_xhr_request @@ -1264,13 +1264,13 @@ class RenderTest < ActionController::TestCase def test_partial_only get :partial_only assert_equal "only partial", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_should_render_html_formatted_partial get :partial assert_equal "partial html", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_render_html_formatted_partial_even_with_other_mime_time_in_accept @@ -1279,20 +1279,20 @@ class RenderTest < ActionController::TestCase get :partial_html_erb assert_equal "partial.html.erb", @response.body.strip - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_should_render_html_partial_with_formats get :partial_formats_html assert_equal "partial html", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_render_to_string_partial get :render_to_string_with_partial assert_equal "only partial", @controller.instance_variable_get(:@partial_only) assert_equal "Hello: david", @controller.instance_variable_get(:@partial_with_locals) - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_render_to_string_with_template_and_html_partial @@ -1300,21 +1300,21 @@ class RenderTest < ActionController::TestCase assert_equal "**only partial**\n", @controller.instance_variable_get(:@text) assert_equal "only partial\n", @controller.instance_variable_get(:@html) assert_equal "only html partial\n", @response.body - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_render_to_string_and_render_with_different_formats get :render_to_string_and_render_with_different_formats assert_equal "only partial\n", @controller.instance_variable_get(:@html) assert_equal "**only partial**\n", @response.body - assert_equal "text/plain", @response.content_type + assert_equal "text/plain", @response.media_type end def test_render_template_within_a_template_with_other_format get :render_template_within_a_template_with_other_format expected = "only html partial

This is grand!

" assert_equal expected, @response.body.strip - assert_equal "text/html", @response.content_type + assert_equal "text/html", @response.media_type end def test_partial_with_counter -- cgit v1.2.3