From 45f8848ca7d7a1065c4c9f3d73946d908a382a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 2 Dec 2016 16:42:37 -0500 Subject: Remove unused argument Now Text class is only used to render text mime type pages --- actionview/test/template/text_test.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/text_test.rb b/actionview/test/template/text_test.rb index 6510688f97..ee526dc367 100644 --- a/actionview/test/template/text_test.rb +++ b/actionview/test/template/text_test.rb @@ -1,17 +1,7 @@ require "abstract_unit" class TextTest < ActiveSupport::TestCase - test "formats returns symbol for recognized MIME type" do - assert_equal [:text], ActionView::Template::Text.new("", :text).formats - end - - test "formats returns string for recognized MIME type when MIME does not have symbol" do - foo = Mime::Type.lookup("foo") - assert_nil foo.to_sym - assert_equal ["foo"], ActionView::Template::Text.new("", foo).formats - end - - test "formats returns string for unknown MIME type" do - assert_equal ["foo"], ActionView::Template::Text.new("", "foo").formats + test "formats always return :text" do + assert_equal [:text], ActionView::Template::Text.new("").formats end end -- cgit v1.2.3 From d71f289fb29d7818620725346ed42ea6952708fa Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 3 Dec 2016 15:28:59 +0900 Subject: stop using removed `render :text` Follow up to 79a5ea9eadb4d43b62afacedc0706cbe88c54496 --- actionview/test/ujs/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/test') diff --git a/actionview/test/ujs/server.rb b/actionview/test/ujs/server.rb index c7698c87fa..cc02cd8419 100644 --- a/actionview/test/ujs/server.rb +++ b/actionview/test/ujs/server.rb @@ -96,7 +96,7 @@ class TestsController < ActionController::Base render html: html.html_safe else - render text: "ERROR: #{request.path} requested without ajax", status: 404 + render plain: "ERROR: #{request.path} requested without ajax", status: 404 end end end -- cgit v1.2.3 From 7407d35c5417b6ef872663936a5880ede8ab711c Mon Sep 17 00:00:00 2001 From: Toshimaru Date: Fri, 9 Dec 2016 03:08:17 +0900 Subject: Enable `block` variable in view Remove `block` keyword from reserved method names --- actionview/test/fixtures/test/test_template_with_block_variable.erb | 1 + actionview/test/template/compiled_templates_test.rb | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 actionview/test/fixtures/test/test_template_with_block_variable.erb (limited to 'actionview/test') diff --git a/actionview/test/fixtures/test/test_template_with_block_variable.erb b/actionview/test/fixtures/test/test_template_with_block_variable.erb new file mode 100644 index 0000000000..2ee6a2bbdc --- /dev/null +++ b/actionview/test/fixtures/test/test_template_with_block_variable.erb @@ -0,0 +1 @@ +<%= block %> \ No newline at end of file diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb index 3ecac46d34..a24a245442 100644 --- a/actionview/test/template/compiled_templates_test.rb +++ b/actionview/test/template/compiled_templates_test.rb @@ -14,6 +14,10 @@ class CompiledTemplatesTest < ActiveSupport::TestCase render(file: "test/render_file_with_ruby_keyword_locals", locals: { class: "foo" }) end + def test_template_with_block_variable + assert_equal "foo", render(file: "test/test_template_with_block_variable", locals: { block: "foo" }) + end + def test_template_with_invalid_identifier_locals locals = { foo: "bar", -- cgit v1.2.3 From d9ff835b99ff3c7567ccde9b1379b4deeabee32f Mon Sep 17 00:00:00 2001 From: Toshimaru Date: Fri, 9 Dec 2016 04:55:21 +0900 Subject: split DELEGATION_RESERVED_METHOD_NAMES in half --- .../fixtures/test/test_template_with_block_variable.erb | 1 - .../test_template_with_delegation_reserved_keywords.erb | 1 + actionview/test/template/compiled_templates_test.rb | 14 ++++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 actionview/test/fixtures/test/test_template_with_block_variable.erb create mode 100644 actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb (limited to 'actionview/test') diff --git a/actionview/test/fixtures/test/test_template_with_block_variable.erb b/actionview/test/fixtures/test/test_template_with_block_variable.erb deleted file mode 100644 index 2ee6a2bbdc..0000000000 --- a/actionview/test/fixtures/test/test_template_with_block_variable.erb +++ /dev/null @@ -1 +0,0 @@ -<%= block %> \ No newline at end of file diff --git a/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb b/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb new file mode 100644 index 0000000000..edfe52e422 --- /dev/null +++ b/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb @@ -0,0 +1 @@ +<%= _ %> <%= arg %> <%= args %> <%= block %> \ No newline at end of file diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb index a24a245442..40ac867b38 100644 --- a/actionview/test/template/compiled_templates_test.rb +++ b/actionview/test/template/compiled_templates_test.rb @@ -14,10 +14,6 @@ class CompiledTemplatesTest < ActiveSupport::TestCase render(file: "test/render_file_with_ruby_keyword_locals", locals: { class: "foo" }) end - def test_template_with_block_variable - assert_equal "foo", render(file: "test/test_template_with_block_variable", locals: { block: "foo" }) - end - def test_template_with_invalid_identifier_locals locals = { foo: "bar", @@ -28,6 +24,16 @@ class CompiledTemplatesTest < ActiveSupport::TestCase assert_equal locals.inspect, render(file: "test/render_file_inspect_local_assigns", locals: locals) end + def test_template_with_delegation_reserved_keywords + locals = { + _: "one", + arg: "two", + args: "three", + block: "four", + } + assert_equal "one two three four", render(file: "test/test_template_with_delegation_reserved_keywords", locals: locals) + end + def test_template_with_unicode_identifier assert_equal "🎂", render(file: "test/render_file_unicode_local", locals: { 🎃: "🎂" }) end -- cgit v1.2.3 From a6d065e39f9285119d75a05ee46c659f8b3c0db8 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Mon, 21 Nov 2016 21:48:38 +0100 Subject: form_with/fields: Don't output ids by default Continuing 67f81cc where we decided not to output ids by default in the new form helpers. Went with @dhh's suggestion of just requiring ids on fields being labelled: https://github.com/rails/rails/issues/25197#issuecomment-231797117 Seems okay enough. --- .../test/template/form_helper/form_with_test.rb | 400 ++++++++++----------- 1 file changed, 200 insertions(+), 200 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c80a2f61b9..4efc93ca08 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -301,10 +301,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", "create-post", method: "patch") do "" + - "" + - "" + + "" + + "" + "" + - "" + + "" + "" + "" + "" @@ -322,9 +322,9 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + - "" + + "" + "" + - "" + + "" + "" end @@ -345,10 +345,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + "" + "" end @@ -371,12 +371,12 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -392,9 +392,9 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + - "" + + "" + "" + - "" + + "" + "" end @@ -411,11 +411,11 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + - "" + + "" + "" + - "" + + "" + "" + - "" + + "" + "" end @@ -436,13 +436,13 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + "" + "" + "" end @@ -466,15 +466,15 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + "" + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -491,7 +491,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts") do "" + - "" + + "" + "" end @@ -506,7 +506,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch", multipart: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -522,7 +522,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch", multipart: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -561,7 +561,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/44", method: "patch") do - "" + + "" + "" end @@ -579,10 +579,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", "create-post", method: "patch") do "" + - "" + - "" + + "" + + "" + "" + - "" + + "" + "" end @@ -609,10 +609,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "delete") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -626,10 +626,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "delete") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -643,7 +643,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/search", "search-post", method: "get") do - "" + "" end assert_dom_equal expected, output_buffer @@ -657,10 +657,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post", method: "patch") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -672,7 +672,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", skip_enforcing_utf8: true) do - "" + "" end assert_dom_equal expected, output_buffer @@ -684,7 +684,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", skip_enforcing_utf8: false) do - "" + "" end assert_dom_equal expected, output_buffer @@ -698,10 +698,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/", "create-post") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -717,10 +717,10 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "" + - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -734,10 +734,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -752,7 +752,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "
" + - "
" + + "
" + "" end @@ -770,7 +770,7 @@ class FormWithActsLikeFormForTest < FormWithTest expected = whole_form("/posts/123", method: "patch") do "
" + - "
" + + "
" + "" end @@ -800,10 +800,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -877,7 +877,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -897,7 +897,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form do - "" + "" end assert_dom_equal expected, output_buffer @@ -912,8 +912,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + - "" + "" + + "" end assert_dom_equal expected, output_buffer @@ -928,8 +928,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + - "" + "" + + "" end assert_dom_equal expected, output_buffer @@ -943,7 +943,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -957,7 +957,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -971,7 +971,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -985,7 +985,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -999,7 +999,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1019,9 +1019,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end + whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1038,8 +1038,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1065,9 +1065,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1084,9 +1084,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1103,8 +1103,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1121,8 +1121,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1139,9 +1139,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1159,9 +1159,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1180,11 +1180,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1207,11 +1207,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1234,10 +1234,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1260,11 +1260,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1283,11 +1283,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1307,11 +1307,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1330,9 +1330,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1351,10 +1351,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1369,7 +1369,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + '' end assert_dom_equal expected, output_buffer @@ -1386,11 +1386,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1407,11 +1407,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1442,11 +1442,11 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1465,10 +1465,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1485,8 +1485,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1502,8 +1502,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1525,8 +1525,8 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + '' + + '' end assert_dom_equal expected, output_buffer @@ -1611,18 +1611,18 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' end assert_dom_equal expected, output_buffer @@ -1638,7 +1638,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - '' + '' end assert_dom_equal expected, output_buffer @@ -1652,10 +1652,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1668,10 +1668,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1684,10 +1684,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1700,10 +1700,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1716,10 +1716,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1732,10 +1732,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "" + - "" + + "" + + "" + "" + - "" + "" assert_dom_equal expected, output_buffer end @@ -1747,7 +1747,7 @@ class FormWithActsLikeFormForTest < FormWithTest end assert_dom_equal "" + - "", + "", output_buffer end @@ -1758,7 +1758,7 @@ class FormWithActsLikeFormForTest < FormWithTest end assert_dom_equal "" + - "", + "", output_buffer end @@ -1777,10 +1777,10 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch") do - "" + - "" + + "" + + "" + "" + - "" + "" end assert_dom_equal expected, output_buffer @@ -1797,9 +1797,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", "create-post", method: "patch") do - "" + - "" + - "" + "" + + "" + + "" end assert_dom_equal expected, output_buffer @@ -1813,7 +1813,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -1837,9 +1837,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" + - "
" + - "
" + "
" + + "
" + + "
" end assert_dom_equal expected, output_buffer @@ -1856,9 +1856,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" + - "
" + - "
" + "
" + + "
" + + "
" end assert_dom_equal expected, output_buffer @@ -1875,7 +1875,7 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = whole_form("/posts/123", method: "patch") do - "
" + "
" end assert_dom_equal expected, output_buffer @@ -1890,7 +1890,7 @@ class FormWithActsLikeFormForTest < FormWithTest concat f.text_field(:title) end - expected = "
" + expected = "
" assert_dom_equal expected, output_buffer end @@ -1902,7 +1902,7 @@ class FormWithActsLikeFormForTest < FormWithTest concat f.text_field(:title) end - expected = "
" + expected = "
" assert_dom_equal expected, output_buffer end @@ -1915,9 +1915,9 @@ class FormWithActsLikeFormForTest < FormWithTest end expected = - "
" + - "
" + - "
" + "
" + + "
" + + "
" assert_dom_equal expected, output_buffer end -- cgit v1.2.3 From 5b217c3a7f294a74d4680e71ef64047432b9ffc2 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Thu, 15 Dec 2016 01:40:22 -0500 Subject: Avoid invalid attribute on local forms generated by `form_with` Fixes that the following ERB template would result in invalid HTML output: <%= form_with model: Post.new, local: true do |form| %> <% end %> Specifically, the resulting form tag would have a spurious `remote` attribute:
--- actionview/test/template/form_helper/form_with_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 4efc93ca08..c078b47e14 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -116,6 +116,16 @@ class FormWithActsLikeFormTagTest < FormWithTest assert_dom_equal expected, output_buffer end + + def test_form_with_with_block_in_erb_and_local_true + output_buffer = render_erb("<%= form_with(url: 'http://www.example.com', local: true) do %>Hello world!<% end %>") + + expected = whole_form("http://www.example.com", local: true) do + "Hello world!" + end + + assert_dom_equal expected, output_buffer + end end class FormWithActsLikeFormForTest < FormWithTest -- cgit v1.2.3 From 9f0f7ec2223ae60ee6e2eab5bc9f036a480e9f81 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 18 Dec 2016 20:01:54 +0100 Subject: form_with: allow methods outside the model. Has the handy effect of making the initial examples in the form_with docs work too. Had to do some finagling such that form_with's without a scope didn't wrap their names in braces ala `[title]`. --- .../test/template/form_helper/form_with_test.rb | 81 ++++++++++++++++++---- 1 file changed, 69 insertions(+), 12 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c078b47e14..96b797992f 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -323,6 +323,75 @@ class FormWithActsLikeFormForTest < FormWithTest assert_dom_equal expected, output_buffer end + def test_form_with_only_url_on_create + form_with(url: "/posts") do |f| + concat f.label :title, "Label me" + concat f.text_field :title + end + + expected = whole_form("/posts") do + '' + + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_form_with_only_url_on_update + form_with(url: "/posts/123") do |f| + concat f.label :title, 'Label me' + concat f.text_field :title + end + + expected = whole_form("/posts/123") do + '' + + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_form_with_general_attributes + form_with(url: "/posts/123") do |f| + concat f.text_field :no_model_to_back_this_badboy + end + + expected = whole_form("/posts/123") do + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_form_with_attribute_not_on_model + form_with(model: @post) do |f| + concat f.text_field :this_dont_exist_on_post + end + + expected = whole_form("/posts/123", method: :patch) do + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_form_with_doesnt_call_private_or_protected_properties_on_form_object_skipping_value + obj = Class.new do + private def private_property + "That would be great." + end + + protected def protected_property + "I believe you have my stapler." + end + end.new + + form_with(model: obj, scope: "other_name", url: "/", id: "edit-other-name") do |f| + assert_dom_equal '', f.hidden_field(:private_property) + assert_dom_equal '', f.hidden_field(:protected_property) + end + end + def test_form_with_with_collection_radio_buttons post = Post.new def post.active; false; end @@ -599,18 +668,6 @@ class FormWithActsLikeFormForTest < FormWithTest assert_dom_equal expected, output_buffer end - def test_form_tags_do_not_call_private_properties_on_form_object - obj = Class.new do - private def private_property - raise "This method should not be called." - end - end.new - - form_with(model: obj, scope: "other_name", url: "/", id: "edit-other-name") do |f| - assert_raise(NoMethodError) { f.hidden_field(:private_property) } - end - end - def test_form_with_with_method_as_part_of_html_options form_with(model: @post, url: "/", id: "create-post", html: { method: :delete }) do |f| concat f.text_field(:title) -- cgit v1.2.3 From b2672c739b9fe3a5b37249d899bdec9c3b9726cf Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 18 Dec 2016 20:17:52 +0100 Subject: fields: support attributes not on model. Ensure the support works like form_with. --- .../test/template/form_helper/form_with_test.rb | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 96b797992f..dd0883e071 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -935,6 +935,41 @@ class FormWithActsLikeFormForTest < FormWithTest end end + def test_fields_with_attributes_not_on_model + form_with(model: @post) do |f| + concat f.fields(:comment) { |c| + concat c.text_field :dont_exist_on_model + } + end + + expected = whole_form("/posts/123", method: :patch) do + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_fields_with_attributes_not_on_model_deep_nested + @comment.save + form_with(scope: :posts) do |f| + f.fields("post[]", model: @post) do |f2| + f2.text_field(:id) + @post.comments.each do |comment| + concat f2.fields("comment[]", model: comment) { |c| + concat c.text_field(:dont_exist_on_model) + } + end + end + end + + expected = whole_form do + '' + end + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields @comment.body = "Hello World" form_with(model: @post) do |f| -- cgit v1.2.3 From be984f02db145c0091c265babd331127c3b408d9 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Dec 2016 23:31:30 +0900 Subject: Unneeded attr_accessor with side effects --- actionview/test/template/form_helper/form_with_test.rb | 4 ---- actionview/test/template/form_helper_test.rb | 4 ---- 2 files changed, 8 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index dd0883e071..3d93e89bcb 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -578,8 +578,6 @@ class FormWithActsLikeFormForTest < FormWithTest end def test_form_with_with_file_field_generate_multipart - Post.send :attr_accessor, :file - form_with(model: @post, id: "create-post") do |f| concat f.file_field(:file) end @@ -592,8 +590,6 @@ class FormWithActsLikeFormForTest < FormWithTest end def test_fields_with_file_field_generate_multipart - Comment.send :attr_accessor, :file - form_with(model: @post) do |f| concat f.fields(:comment, model: @post) { |c| concat c.file_field(:file) diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 022bf315ce..4c7134abac 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -1751,8 +1751,6 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_file_field_generate_multipart - Post.send :attr_accessor, :file - form_for(@post, html: { id: "create-post" }) do |f| concat f.file_field(:file) end @@ -1765,8 +1763,6 @@ class FormHelperTest < ActionView::TestCase end def test_fields_for_with_file_field_generate_multipart - Comment.send :attr_accessor, :file - form_for(@post) do |f| concat f.fields_for(:comment, @post) { |c| concat c.file_field(:file) -- cgit v1.2.3 From 1f5bed98551e08b9e8bdfabbfbb0fded665a47c4 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Dec 2016 23:19:23 +0900 Subject: Privatize unneededly protected methods in Action View tests --- actionview/test/abstract_unit.rb | 2 +- actionview/test/activerecord/form_helper_activerecord_test.rb | 2 +- actionview/test/template/form_helper/form_with_test.rb | 2 +- actionview/test/template/form_helper_test.rb | 2 +- actionview/test/template/url_helper_test.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index 88c7189d22..5bc4151087 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -163,7 +163,7 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase # Stub Rails dispatcher so it does not get controller references and # simply return the controller#action as Rack::Body. class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher - protected + private def controller_reference(controller_param) controller_param end diff --git a/actionview/test/activerecord/form_helper_activerecord_test.rb b/actionview/test/activerecord/form_helper_activerecord_test.rb index 6152ec4720..0f7960b408 100644 --- a/actionview/test/activerecord/form_helper_activerecord_test.rb +++ b/actionview/test/activerecord/form_helper_activerecord_test.rb @@ -52,7 +52,7 @@ class FormHelperActiveRecordTest < ActionView::TestCase assert_dom_equal expected, output_buffer end - protected + private def hidden_fields(method = nil) txt = %{} diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 3d93e89bcb..08c685b00f 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -2184,7 +2184,7 @@ class FormWithActsLikeFormForTest < FormWithTest assert_equal 1, initialization_count, "form builder instantiated more than once" end - protected + private def hidden_fields(options = {}) method = options[:method] diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 4c7134abac..4850bc390b 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -3439,7 +3439,7 @@ class FormHelperTest < ActionView::TestCase assert_equal 1, initialization_count, "form builder instantiated more than once" end - protected + private def hidden_fields(options = {}) method = options[:method] diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 5a2319fe96..1e64385b52 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -810,7 +810,7 @@ class TasksController < ActionController::Base render_default end - protected + private def render_default render inline: "<%= link_to_unless_current('tasks', tasks_path) %>\n" + "<%= link_to_unless_current('tasks', tasks_url) %>" -- cgit v1.2.3 From e8ba0c0f21e2660b90f872fa4595156ca6190c77 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 25 Dec 2016 02:29:52 +0900 Subject: "Use assert_nil if expecting nil. This will fail in minitest 6." --- actionview/test/template/asset_tag_helper_test.rb | 2 +- actionview/test/template/capture_helper_test.rb | 14 +++++++------- actionview/test/template/number_helper_test.rb | 14 +++++++------- actionview/test/template/test_case_test.rb | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb index 3bdab42f7a..07a6452cc1 100644 --- a/actionview/test/template/asset_tag_helper_test.rb +++ b/actionview/test/template/asset_tag_helper_test.rb @@ -630,7 +630,7 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase end def test_should_return_nothing_if_asset_host_isnt_configured - assert_equal nil, compute_asset_host("foo") + assert_nil compute_asset_host("foo") end def test_should_current_request_host_is_always_returned_for_request diff --git a/actionview/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb index 54bf9b4c33..7f37523eeb 100644 --- a/actionview/test/template/capture_helper_test.rb +++ b/actionview/test/template/capture_helper_test.rb @@ -127,18 +127,18 @@ class CaptureHelperTest < ActionView::TestCase def test_content_for_returns_nil_when_writing assert ! content_for?(:title) - assert_equal nil, content_for(:title, "foo") - assert_equal nil, content_for(:title) { output_buffer << "bar"; nil } - assert_equal nil, content_for(:title) { output_buffer << " \n "; nil } + assert_nil content_for(:title, "foo") + assert_nil content_for(:title) { output_buffer << "bar"; nil } + assert_nil content_for(:title) { output_buffer << " \n "; nil } assert_equal "foobar", content_for(:title) - assert_equal nil, content_for(:title, "foo", flush: true) - assert_equal nil, content_for(:title, flush: true) { output_buffer << "bar"; nil } - assert_equal nil, content_for(:title, flush: true) { output_buffer << " \n "; nil } + assert_nil content_for(:title, "foo", flush: true) + assert_nil content_for(:title, flush: true) { output_buffer << "bar"; nil } + assert_nil content_for(:title, flush: true) { output_buffer << " \n "; nil } assert_equal "bar", content_for(:title) end def test_content_for_returns_nil_when_content_missing - assert_equal nil, content_for(:some_missing_key) + assert_nil content_for(:some_missing_key) end def test_content_for_question_mark diff --git a/actionview/test/template/number_helper_test.rb b/actionview/test/template/number_helper_test.rb index 2a2ada2b36..678120a9c9 100644 --- a/actionview/test/template/number_helper_test.rb +++ b/actionview/test/template/number_helper_test.rb @@ -4,7 +4,7 @@ class NumberHelperTest < ActionView::TestCase tests ActionView::Helpers::NumberHelper def test_number_to_phone - assert_equal nil, number_to_phone(nil) + assert_nil number_to_phone(nil) assert_equal "555-1234", number_to_phone(5551234) assert_equal "(800) 555-1212 x 123", number_to_phone(8005551212, area_code: true, extension: 123) assert_equal "+18005551212", number_to_phone(8005551212, country_code: 1, delimiter: "") @@ -13,7 +13,7 @@ class NumberHelperTest < ActionView::TestCase end def test_number_to_currency - assert_equal nil, number_to_currency(nil) + assert_nil number_to_currency(nil) assert_equal "$1,234,567,890.50", number_to_currency(1234567890.50) assert_equal "$1,234,567,892", number_to_currency(1234567891.50, precision: 0) assert_equal "1,234,567,890.50 - Kč", number_to_currency("-1234567890.50", unit: raw("Kč"), format: "%n %u", negative_format: "%n - %u") @@ -25,7 +25,7 @@ class NumberHelperTest < ActionView::TestCase end def test_number_to_percentage - assert_equal nil, number_to_percentage(nil) + assert_nil number_to_percentage(nil) assert_equal "100.000%", number_to_percentage(100) assert_equal "100.000 %", number_to_percentage(100, format: "%n %") assert_equal "<b>100.000</b> %", number_to_percentage(100, format: "%n %") @@ -43,13 +43,13 @@ class NumberHelperTest < ActionView::TestCase end def test_number_with_delimiter - assert_equal nil, number_with_delimiter(nil) + assert_nil number_with_delimiter(nil) assert_equal "12,345,678", number_with_delimiter(12345678) assert_equal "0", number_with_delimiter(0) end def test_number_with_precision - assert_equal nil, number_with_precision(nil) + assert_nil number_with_precision(nil) assert_equal "-111.235", number_with_precision(-111.2346) assert_equal "111.00", number_with_precision(111, precision: 2) assert_equal "0.00100", number_with_precision(0.001, precision: 5) @@ -57,13 +57,13 @@ class NumberHelperTest < ActionView::TestCase end def test_number_to_human_size - assert_equal nil, number_to_human_size(nil) + assert_nil number_to_human_size(nil) assert_equal "3 Bytes", number_to_human_size(3.14159265) assert_equal "1.2 MB", number_to_human_size(1234567, precision: 2) end def test_number_to_human - assert_equal nil, number_to_human(nil) + assert_nil number_to_human(nil) assert_equal "0", number_to_human(0) assert_equal "1.23 Thousand", number_to_human(1234) assert_equal "489.0 Thousand", number_to_human(489000, precision: 4, strip_insignificant_zeros: false) diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index 41225000f0..3deddd5706 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -50,7 +50,7 @@ module ActionView end test "retrieve non existing config values" do - assert_equal nil, ActionView::Base.new.config.something_odd + assert_nil ActionView::Base.new.config.something_odd end test "works without testing a helper module" do -- cgit v1.2.3 From a46b2f8911c5730c8c56d487b65f7c5627d334ee Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 26 Dec 2016 11:04:41 +0900 Subject: assert_equal takes expectation first --- actionview/test/template/form_tag_helper_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (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 24ae6b8b90..088f5ae122 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -694,31 +694,31 @@ class FormTagHelperTest < ActionView::TestCase def test_text_area_tag_options_symbolize_keys_side_effects options = { option: "random_option" } text_area_tag "body", "hello world", options - assert_equal options, option: "random_option" + assert_equal({option: "random_option"}, options) end def test_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } submit_tag "submit value", options - assert_equal options, option: "random_option" + assert_equal({option: "random_option"}, options) end def test_button_tag_options_symbolize_keys_side_effects options = { option: "random_option" } button_tag "button value", options - assert_equal options, option: "random_option" + assert_equal({option: "random_option"}, options) end def test_image_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } image_submit_tag "submit source", options - assert_equal options, option: "random_option" + assert_equal({option: "random_option"}, options) end def test_image_label_tag_options_symbolize_keys_side_effects options = { option: "random_option" } label_tag "submit source", "title", options - assert_equal options, option: "random_option" + assert_equal({option: "random_option"}, options) end def protect_against_forgery? -- cgit v1.2.3 From ebeeceeb2aa34d33337f991607debae715ca061a Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 27 Dec 2016 12:47:31 +0900 Subject: do not mutate `object_name` of class in `fields_for` Since it affects the entire form, should not mutate `object_name` of class. Fixes #26931 --- actionview/test/template/form_helper_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 4850bc390b..3da3b95114 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -2262,11 +2262,13 @@ class FormHelperTest < ActionView::TestCase concat f.fields_for("comment[]", @comment) { |c| concat c.text_field(:name) } + concat f.text_field(:body) end expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" + - "" + "" + + "" end assert_dom_equal expected, output_buffer -- cgit v1.2.3 From 010e246756c09f44e901f4fd8e8eab2cb3022e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 28 Dec 2016 21:53:51 -0500 Subject: Fix Rubocop violations and fix documentation visibility Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API. --- .../test/template/form_helper/form_with_test.rb | 3 +-- actionview/test/template/form_helper_test.rb | 6 ++--- actionview/test/template/form_tag_helper_test.rb | 10 ++++----- actionview/test/ujs/config.ru | 4 ++-- actionview/test/ujs/server.rb | 26 +++++++++++----------- 5 files changed, 24 insertions(+), 25 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 08c685b00f..3a91c7dce7 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -339,7 +339,7 @@ class FormWithActsLikeFormForTest < FormWithTest def test_form_with_only_url_on_update form_with(url: "/posts/123") do |f| - concat f.label :title, 'Label me' + concat f.label :title, "Label me" concat f.text_field :title end @@ -965,7 +965,6 @@ class FormWithActsLikeFormForTest < FormWithTest assert_dom_equal expected, output_buffer end - def test_nested_fields @comment.body = "Hello World" form_with(model: @post) do |f| diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 4850bc390b..a345adfe6c 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -1829,9 +1829,9 @@ class FormHelperTest < ActionView::TestCase obj = Class.new do private - def private_property - raise "This method should not be called." - end + def private_property + raise "This method should not be called." + end end.new form_for(obj, as: "other_name", url: "/", html: { id: "edit-other-name" }) do |f| diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 088f5ae122..1248a0bb09 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -694,31 +694,31 @@ class FormTagHelperTest < ActionView::TestCase def test_text_area_tag_options_symbolize_keys_side_effects options = { option: "random_option" } text_area_tag "body", "hello world", options - assert_equal({option: "random_option"}, options) + assert_equal({ option: "random_option" }, options) end def test_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } submit_tag "submit value", options - assert_equal({option: "random_option"}, options) + assert_equal({ option: "random_option" }, options) end def test_button_tag_options_symbolize_keys_side_effects options = { option: "random_option" } button_tag "button value", options - assert_equal({option: "random_option"}, options) + assert_equal({ option: "random_option" }, options) end def test_image_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } image_submit_tag "submit source", options - assert_equal({option: "random_option"}, options) + assert_equal({ option: "random_option" }, options) end def test_image_label_tag_options_symbolize_keys_side_effects options = { option: "random_option" } label_tag "submit source", "title", options - assert_equal({option: "random_option"}, options) + assert_equal({ option: "random_option" }, options) end def protect_against_forgery? diff --git a/actionview/test/ujs/config.ru b/actionview/test/ujs/config.ru index cb961dc140..414c2063c3 100644 --- a/actionview/test/ujs/config.ru +++ b/actionview/test/ujs/config.ru @@ -1,3 +1,3 @@ -$LOAD_PATH.unshift File.expand_path('..', __FILE__) -require 'server' +$LOAD_PATH.unshift File.expand_path("..", __FILE__) +require "server" run UJS::Server diff --git a/actionview/test/ujs/server.rb b/actionview/test/ujs/server.rb index cc02cd8419..25f70baf5f 100644 --- a/actionview/test/ujs/server.rb +++ b/actionview/test/ujs/server.rb @@ -12,7 +12,7 @@ module UJS get "/rails-ujs.js" => Blade::Assets.environment get "/" => "tests#index" match "/echo" => "tests#echo", via: :all - get "/error" => proc {|env| [403, {}, []] } + get "/error" => proc { |env| [403, {}, []] } end config.cache_classes = false @@ -26,7 +26,7 @@ module UJS end module TestsHelper - def jquery_link version + def jquery_link(version) if params[:version] == version "[#{version}]" else @@ -34,7 +34,7 @@ module TestsHelper end end - def cdn_link cdn + def cdn_link(cdn) if params[:cdn] == cdn "[#{cdn}]" else @@ -43,22 +43,22 @@ module TestsHelper end def jquery_src - if params[:version] == 'edge' + if params[:version] == "edge" "/vendor/jquery.js" - elsif params[:cdn] && params[:cdn] == 'googleapis' + elsif params[:cdn] && params[:cdn] == "googleapis" "https://ajax.googleapis.com/ajax/libs/jquery/#{params[:version]}/jquery.min.js" else "http://code.jquery.com/jquery-#{params[:version]}.js" end end - def test_to *names + def test_to(*names) names = ["/vendor/qunit.js", "settings"] + names names.map { |name| script_tag name }.join("\n").html_safe end - def script_tag src - src = "/test/#{src}.js" unless src.index('/') + def script_tag(src) + src = "/test/#{src}.js" unless src.index("/") %().html_safe end @@ -72,20 +72,20 @@ class TestsController < ActionController::Base layout "application" def index - params[:version] ||= ENV['JQUERY_VERSION'] || '1.11.0' - params[:cdn] ||= 'jquery' + params[:version] ||= ENV["JQUERY_VERSION"] || "1.11.0" + params[:cdn] ||= "jquery" render :index end def echo - data = { :params => params.to_unsafe_h }.update(request.env) + data = { params: params.to_unsafe_h }.update(request.env) - if params[:content_type] and params[:content] + if params[:content_type] && params[:content] render inline: params[:content], content_type: params[:content_type] elsif request.xhr? render json: JSON.generate(data) elsif params[:iframe] - payload = JSON.generate(data).gsub('<', '<').gsub('>', '>') + payload = JSON.generate(data).gsub("<", "<").gsub(">", ">") html = <<-HTML