From 80e66cc4d90bf8c15d1a5f6e3152e90147f00772 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 19:55:02 +0200 Subject: normalizes indentation and whitespace across the project --- actionview/test/abstract_unit.rb | 20 ++-- .../abstract/abstract_controller_test.rb | 32 +++--- .../test/actionpack/abstract/layouts_test.rb | 12 +-- .../activerecord/form_helper_activerecord_test.rb | 48 ++++----- .../helpers_missing/invalid_require_helper.rb | 1 - actionview/test/fixtures/mascot.rb | 2 +- actionview/test/template/atom_feed_helper_test.rb | 16 +-- actionview/test/template/date_helper_test.rb | 6 +- actionview/test/template/form_helper_test.rb | 108 ++++++++++----------- .../test/template/form_options_helper_test.rb | 80 +++++++-------- actionview/test/template/form_tag_helper_test.rb | 6 +- actionview/test/template/tag_helper_test.rb | 2 +- 12 files changed, 166 insertions(+), 167 deletions(-) (limited to 'actionview/test') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index 92989dfbe8..1d1e938557 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -164,13 +164,13 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase # simply return the controller#action as Rack::Body. class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher protected - def controller_reference(controller_param) - controller_param - end + def controller_reference(controller_param) + controller_param + end - def dispatch(controller, action, env) - [200, {"Content-Type" => "text/html"}, ["#{controller}##{action}"]] - end + def dispatch(controller, action, env) + [200, {"Content-Type" => "text/html"}, ["#{controller}##{action}"]] + end end def self.stub_controllers @@ -263,11 +263,11 @@ end module ActionDispatch class DebugExceptions private - remove_method :stderr_logger + remove_method :stderr_logger # Silence logger - def stderr_logger - nil - end + def stderr_logger + nil + end end end diff --git a/actionview/test/actionpack/abstract/abstract_controller_test.rb b/actionview/test/actionpack/abstract/abstract_controller_test.rb index 1480445fc5..9989b5a377 100644 --- a/actionview/test/actionpack/abstract/abstract_controller_test.rb +++ b/actionview/test/actionpack/abstract/abstract_controller_test.rb @@ -114,13 +114,13 @@ module AbstractController # * self._prefix is used when defined class PrefixedViews < RenderingController private - def self.prefix - name.underscore - end + def self.prefix + name.underscore + end - def _prefixes - [self.class.prefix] - end + def _prefixes + [self.class.prefix] + end end class Me3 < PrefixedViews @@ -189,19 +189,19 @@ module AbstractController include ActionView::Layouts private - def self.layout(formats) - find_template(name.underscore, {formats: formats}, _prefixes: ["layouts"]) - rescue ActionView::MissingTemplate - begin - find_template("application", {formats: formats}, _prefixes: ["layouts"]) + def self.layout(formats) + find_template(name.underscore, {formats: formats}, _prefixes: ["layouts"]) rescue ActionView::MissingTemplate + begin + find_template("application", {formats: formats}, _prefixes: ["layouts"]) + rescue ActionView::MissingTemplate + end end - end - def render_to_body(options = {}) - options[:_layout] = options[:layout] || _default_layout({}) - super - end + def render_to_body(options = {}) + options[:_layout] = options[:layout] || _default_layout({}) + super + end end class Me4 < WithLayouts diff --git a/actionview/test/actionpack/abstract/layouts_test.rb b/actionview/test/actionpack/abstract/layouts_test.rb index e9352dcc35..e4abac1315 100644 --- a/actionview/test/actionpack/abstract/layouts_test.rb +++ b/actionview/test/actionpack/abstract/layouts_test.rb @@ -422,16 +422,16 @@ module AbstractControllerTests test "when a grandchild has no layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the child controller layout" do - controller = WithChildOfImplied.new - controller.process(:index) - assert_equal "With Implied Hello string!", controller.response_body + controller = WithChildOfImplied.new + controller.process(:index) + assert_equal "With Implied Hello string!", controller.response_body end test "when a grandchild has nil layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the grand child controller layout" do - controller = WithGrandChildOfImplied.new - controller.process(:index) - assert_equal "With Grand Child Hello string!", controller.response_body + controller = WithGrandChildOfImplied.new + controller.process(:index) + assert_equal "With Grand Child Hello string!", controller.response_body end test "a child inherits layout from abstract controller" do diff --git a/actionview/test/activerecord/form_helper_activerecord_test.rb b/actionview/test/activerecord/form_helper_activerecord_test.rb index 8c83c536c1..6152ec4720 100644 --- a/actionview/test/activerecord/form_helper_activerecord_test.rb +++ b/actionview/test/activerecord/form_helper_activerecord_test.rb @@ -54,35 +54,35 @@ class FormHelperActiveRecordTest < ActionView::TestCase protected - def hidden_fields(method = nil) - txt = %{} + def hidden_fields(method = nil) + txt = %{} - if method && !%w(get post).include?(method.to_s) - txt << %{} + if method && !%w(get post).include?(method.to_s) + txt << %{} + end + + txt end - txt - end + def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) + txt = %{
} + end - def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{} - end + def whole_form(action = "/", id = nil, html_class = nil, options = nil) + contents = block_given? ? yield : "" - def whole_form(action = "/", id = nil, html_class = nil, options = nil) - contents = block_given? ? yield : "" + if options.is_a?(Hash) + method, remote, multipart = options.values_at(:method, :remote, :multipart) + else + method = options + end - if options.is_a?(Hash) - method, remote, multipart = options.values_at(:method, :remote, :multipart) - else - method = options + form_text(action, id, html_class, remote, multipart, method) + hidden_fields(method) + contents + "
" end - - form_text(action, id, html_class, remote, multipart, method) + hidden_fields(method) + contents + "" - end end diff --git a/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb b/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb index 93927f1bdb..6ac6677daa 100644 --- a/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb +++ b/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb @@ -2,4 +2,3 @@ require "very_invalid_file_name" module InvalidRequireHelper end - diff --git a/actionview/test/fixtures/mascot.rb b/actionview/test/fixtures/mascot.rb index f9f1448b8f..1c0bd7c8fd 100644 --- a/actionview/test/fixtures/mascot.rb +++ b/actionview/test/fixtures/mascot.rb @@ -1,3 +1,3 @@ class Mascot < ActiveRecord::Base belongs_to :company -end \ No newline at end of file +end diff --git a/actionview/test/template/atom_feed_helper_test.rb b/actionview/test/template/atom_feed_helper_test.rb index a8b95acdea..e9a923dd72 100644 --- a/actionview/test/template/atom_feed_helper_test.rb +++ b/actionview/test/template/atom_feed_helper_test.rb @@ -28,7 +28,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["entry_options"] = <<-EOT + FEEDS["entry_options"] = <<-EOT atom_feed do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -45,7 +45,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["entry_type_options"] = <<-EOT + FEEDS["entry_type_options"] = <<-EOT atom_feed(:schema_date => '2008') do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -62,7 +62,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["entry_url_false_option"] = <<-EOT + FEEDS["entry_url_false_option"] = <<-EOT atom_feed do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -79,7 +79,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["xml_block"] = <<-EOT + FEEDS["xml_block"] = <<-EOT atom_feed do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -96,7 +96,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["feed_with_atomPub_namespace"] = <<-EOT + FEEDS["feed_with_atomPub_namespace"] = <<-EOT atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app', 'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed| feed.title("My great blog!") @@ -115,7 +115,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["feed_with_overridden_ids"] = <<-EOT + FEEDS["feed_with_overridden_ids"] = <<-EOT atom_feed({:id => 'tag:test.rubyonrails.org,2008:test/'}) do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -169,7 +169,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["feed_with_xhtml_content"] = <<-'EOT' + FEEDS["feed_with_xhtml_content"] = <<-'EOT' atom_feed do |feed| feed.title("My great blog!") feed.updated(@scrolls.first.created_at) @@ -191,7 +191,7 @@ class ScrollsController < ActionController::Base end end EOT - FEEDS["provide_builder"] = <<-'EOT' + FEEDS["provide_builder"] = <<-'EOT' # we pass in the new_xml to the helper so it doesn't # call anything on the original builder new_xml = Builder::XmlMarkup.new(:target=>'') diff --git a/actionview/test/template/date_helper_test.rb b/actionview/test/template/date_helper_test.rb index 0f1f22c43a..a40bc1c131 100644 --- a/actionview/test/template/date_helper_test.rb +++ b/actionview/test/template/date_helper_test.rb @@ -534,7 +534,7 @@ class DateHelperTest < ActionView::TestCase assert_dom_equal expected, select_year(nil, start_year: 2003, end_year: 2005, with_css_classes: { year: "my-year" }) end - + def test_select_year_with_position expected = %(\n" expected << " : " expected << %(\n" @@ -2524,7 +2524,7 @@ class DateHelperTest < ActionView::TestCase expected << "\n" expected << " : " expected << %(\n" diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 716cb3a00a..ed58818602 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -805,9 +805,9 @@ class FormHelperTest < ActionView::TestCase end def test_radio_button_respects_passed_in_id - assert_dom_equal('', - radio_button("post", "secret", "1", id: "foo") - ) + assert_dom_equal('', + radio_button("post", "secret", "1", id: "foo") + ) end def test_radio_button_with_booleans @@ -1443,10 +1443,10 @@ class FormHelperTest < ActionView::TestCase %{}, check_box("post[]", "secret") ) - assert_dom_equal( - %{}, - radio_button("post[]", "title", "Hello World") - ) + assert_dom_equal( + %{}, + radio_button("post[]", "title", "Hello World") + ) assert_dom_equal( %{}, radio_button("post[]", "title", "Goodbye World") @@ -1467,10 +1467,10 @@ class FormHelperTest < ActionView::TestCase %{}, check_box("post[]", "secret", id: nil) ) - assert_dom_equal( - %{}, - radio_button("post[]", "title", "Hello World", id: nil) - ) + assert_dom_equal( + %{}, + radio_button("post[]", "title", "Hello World", id: nil) + ) assert_dom_equal( %{}, radio_button("post[]", "title", "Goodbye World", id: nil) @@ -2187,7 +2187,7 @@ class FormHelperTest < ActionView::TestCase end expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -2201,7 +2201,7 @@ class FormHelperTest < ActionView::TestCase end expected = whole_form do - "" + "" end assert_dom_equal expected, output_buffer @@ -2215,7 +2215,7 @@ class FormHelperTest < ActionView::TestCase end expected = whole_form("/posts/123", "edit_another_post", "edit_another_post", method: "patch") do - "" + "" end assert_dom_equal expected, output_buffer @@ -2419,11 +2419,11 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do - '' + - '' + - '' - end + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -3443,48 +3443,48 @@ class FormHelperTest < ActionView::TestCase protected - def hidden_fields(options = {}) - method = options[:method] + def hidden_fields(options = {}) + method = options[:method] - if options.fetch(:enforce_utf8, true) - txt = %{} - else - txt = "" - end + if options.fetch(:enforce_utf8, true) + txt = %{} + else + txt = "" + end - if method && !%w(get post).include?(method.to_s) - txt << %{} - end + if method && !%w(get post).include?(method.to_s) + txt << %{} + end - txt - end + txt + end - def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{
} - end + def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) + txt = %{} + end - def whole_form(action = "/", id = nil, html_class = nil, options = {}) - contents = block_given? ? yield : "" + def whole_form(action = "/", id = nil, html_class = nil, options = {}) + contents = block_given? ? yield : "" - method, remote, multipart = options.values_at(:method, :remote, :multipart) + method, remote, multipart = options.values_at(:method, :remote, :multipart) - form_text(action, id, html_class, remote, multipart, method) + hidden_fields(options.slice :method, :enforce_utf8) + contents + "
" - end + form_text(action, id, html_class, remote, multipart, method) + hidden_fields(options.slice :method, :enforce_utf8) + contents + "" + end - def protect_against_forgery? - false - end + def protect_against_forgery? + false + end - def with_locale(testing_locale = :label) - old_locale, I18n.locale = I18n.locale, testing_locale - yield - ensure - I18n.locale = old_locale - end + def with_locale(testing_locale = :label) + old_locale, I18n.locale = I18n.locale, testing_locale + yield + ensure + I18n.locale = old_locale + end end diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 69c43dacb0..f588fb2fd2 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -66,10 +66,10 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_collection_options_with_preselected_value_array - assert_dom_equal( - "\n\n", - options_from_collection_for_select(dummy_posts, "author_name", "title", [ "Babe", "Cabe" ]) - ) + assert_dom_equal( + "\n\n", + options_from_collection_for_select(dummy_posts, "author_name", "title", [ "Babe", "Cabe" ]) + ) end def test_collection_options_with_proc_for_selected @@ -171,10 +171,10 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_array_options_for_select_with_selection_array - assert_dom_equal( - "\n\n", - options_for_select([ "Denmark", "", "Sweden" ], [ "", "Sweden" ]) - ) + assert_dom_equal( + "\n\n", + options_for_select([ "Denmark", "", "Sweden" ], [ "", "Sweden" ]) + ) end def test_array_options_for_select_with_disabled_value @@ -213,18 +213,18 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_array_options_for_string_include_in_other_string_bug_fix - assert_dom_equal( - "\n", - options_for_select([ "ruby", "rubyonrails" ], "rubyonrails") - ) - assert_dom_equal( - "\n", - options_for_select([ "ruby", "rubyonrails" ], "ruby") - ) - assert_dom_equal( - %(\n\n), - options_for_select([ "ruby", "rubyonrails", nil ], "ruby") - ) + assert_dom_equal( + "\n", + options_for_select([ "ruby", "rubyonrails" ], "rubyonrails") + ) + assert_dom_equal( + "\n", + options_for_select([ "ruby", "rubyonrails" ], "ruby") + ) + assert_dom_equal( + %(\n\n), + options_for_select([ "ruby", "rubyonrails", nil ], "ruby") + ) end def test_hash_options_for_select @@ -1234,18 +1234,18 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_time_zone_select_with_default_time_zone_and_nil_value - @firm = Firm.new() - @firm.time_zone = nil + @firm = Firm.new() + @firm.time_zone = nil - html = time_zone_select( "firm", "time_zone", nil, default: "B" ) - assert_dom_equal "", - html + html = time_zone_select( "firm", "time_zone", nil, default: "B" ) + assert_dom_equal "", + html end def test_time_zone_select_with_default_time_zone_and_value @@ -1386,14 +1386,14 @@ class FormOptionsHelperTest < ActionView::TestCase private - def dummy_posts - [ Post.new(" went home", "", "To a little house", "shh!"), - Post.new("Babe went home", "Babe", "To a little house", "shh!"), - Post.new("Cabe went home", "Cabe", "To a little house", "shh!") ] - end + def dummy_posts + [ Post.new(" went home", "", "To a little house", "shh!"), + Post.new("Babe went home", "Babe", "To a little house", "shh!"), + Post.new("Cabe went home", "Cabe", "To a little house", "shh!") ] + end - def dummy_continents - [ Continent.new("", [Country.new("", ""), Country.new("so", "Somalia")]), - Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")]) ] - end + def dummy_continents + [ Continent.new("", [Country.new("", ""), Country.new("so", "Somalia")]), + Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")]) ] + end end diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 603fddc09e..52f32e9f0e 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -728,7 +728,7 @@ class FormTagHelperTest < ActionView::TestCase private - def root_elem(rendered_content) - Nokogiri::HTML::DocumentFragment.parse(rendered_content).children.first # extract from nodeset - end + def root_elem(rendered_content) + Nokogiri::HTML::DocumentFragment.parse(rendered_content).children.first # extract from nodeset + end end diff --git a/actionview/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb index 4e691c9490..3e060d0246 100644 --- a/actionview/test/template/tag_helper_test.rb +++ b/actionview/test/template/tag_helper_test.rb @@ -314,7 +314,7 @@ class TagHelperTest < ActionView::TestCase def test_link_to_data_nil_equal div_type1 = content_tag(:div, "test", "data-tooltip" => nil) div_type2 = content_tag(:div, "test", data: {tooltip: nil}) - assert_dom_equal div_type1, div_type2 + assert_dom_equal div_type1, div_type2 end def test_tag_builder_link_to_data_nil_equal -- cgit v1.2.3