diff options
Diffstat (limited to 'actionpack')
10 files changed, 50 insertions, 30 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 8cffa11500..3a6bc92b3c 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -671,11 +671,6 @@ module ActionController end end end - - def html_format?(parameters) - return true unless parameters.key?(:format) - Mime.fetch(parameters[:format]) { Mime["html"] }.html? - end end include Behavior diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb index 1e17cb9777..0c4071df8d 100644 --- a/actionpack/test/abstract/translation_test.rb +++ b/actionpack/test/abstract/translation_test.rb @@ -9,7 +9,8 @@ module AbstractController class TranslationControllerTest < ActiveSupport::TestCase def setup @controller = TranslationController.new - I18n.backend.store_translations(:en, one: { + I18n.backend.store_translations(:en, + one: { two: "bar", }, abstract_controller: { diff --git a/actionpack/test/controller/new_base/render_action_test.rb b/actionpack/test/controller/new_base/render_action_test.rb index e88f83b594..4b59a3d676 100644 --- a/actionpack/test/controller/new_base/render_action_test.rb +++ b/actionpack/test/controller/new_base/render_action_test.rb @@ -258,7 +258,8 @@ end module RenderActionWithBothLayouts class BasicController < ActionController::Base - self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!", + self.view_paths = [ActionView::FixtureResolver.new( + "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!", "layouts/application.html.erb" => "Oh Hi <%= yield %> Bye", "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> Bye")] diff --git a/actionpack/test/controller/parameters/always_permitted_parameters_test.rb b/actionpack/test/controller/parameters/always_permitted_parameters_test.rb index 9c9749c037..cd7c98f112 100644 --- a/actionpack/test/controller/parameters/always_permitted_parameters_test.rb +++ b/actionpack/test/controller/parameters/always_permitted_parameters_test.rb @@ -19,7 +19,8 @@ class AlwaysPermittedParametersTest < ActiveSupport::TestCase end test "permits parameters that are whitelisted" do - params = ActionController::Parameters.new( book: { pages: 65 }, + params = ActionController::Parameters.new( + book: { pages: 65 }, format: "json") permitted = params.permit book: [:pages] assert permitted.permitted? diff --git a/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb b/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb index bf2c3d1ed2..0358fd9976 100644 --- a/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb +++ b/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb @@ -11,7 +11,8 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase end test "logs on unexpected param" do - params = ActionController::Parameters.new( book: { pages: 65 }, + params = ActionController::Parameters.new( + book: { pages: 65 }, fishing: "Turnips") assert_logged("Unpermitted parameter: fishing") do @@ -20,7 +21,8 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase end test "logs on unexpected params" do - params = ActionController::Parameters.new( book: { pages: 65 }, + params = ActionController::Parameters.new( + book: { pages: 65 }, fishing: "Turnips", car: "Mersedes") @@ -30,7 +32,8 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase end test "logs on unexpected nested param" do - params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then." }) + params = ActionController::Parameters.new( + book: { pages: 65, title: "Green Cats and where to find then." }) assert_logged("Unpermitted parameter: title") do params.permit(book: [:pages]) @@ -38,7 +41,8 @@ class LogOnUnpermittedParamsTest < ActiveSupport::TestCase end test "logs on unexpected nested params" do - params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then.", author: "G. A. Dog" }) + params = ActionController::Parameters.new( + book: { pages: 65, title: "Green Cats and where to find then.", author: "G. A. Dog" }) assert_logged("Unpermitted parameters: title, author") do params.permit(book: [:pages]) diff --git a/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb b/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb index 44e39135a2..88fb477c10 100644 --- a/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb +++ b/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb @@ -3,7 +3,8 @@ require "action_controller/metal/strong_parameters" class MultiParameterAttributesTest < ActiveSupport::TestCase test "permitted multi-parameter attribute keys" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { "shipped_at(1i)" => "2012", "shipped_at(2i)" => "3", "shipped_at(3i)" => "25", diff --git a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb index e3f1ba5f0a..f0155477c4 100644 --- a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb @@ -7,7 +7,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "permitted nested parameters" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { title: "Romeo and Juliet", authors: [{ name: "William Shakespeare", @@ -43,7 +44,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "permitted nested parameters with a string or a symbol as a key" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { "authors" => [ { name: "William Shakespeare", born: "1564-04-26" }, { name: "Christopher Marlowe" } @@ -66,7 +68,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "nested arrays with strings" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { genres: ["Tragedy"] }) @@ -75,7 +78,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "permit may specify symbols or strings" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { title: "Romeo and Juliet", author: "William Shakespeare" }, @@ -88,7 +92,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "nested array with strings that should be hashes" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { genres: ["Tragedy"] }) @@ -97,7 +102,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "nested array with strings that should be hashes and additional values" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { title: "Romeo and Juliet", genres: ["Tragedy"] }) @@ -108,7 +114,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "nested string that should be a hash" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { genre: "Tragedy" }) @@ -117,7 +124,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "fields_for-style nested params" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { authors_attributes: { '0': { name: "William Shakespeare", age_of_death: "52" }, '1': { name: "Unattributed Assistant" }, @@ -136,7 +144,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "fields_for-style nested params with negative numbers" do - params = ActionController::Parameters.new( book: { + params = ActionController::Parameters.new( + book: { authors_attributes: { '-1': { name: "William Shakespeare", age_of_death: "52" }, '-2': { name: "Unattributed Assistant" } @@ -153,7 +162,8 @@ class NestedParametersPermitTest < ActiveSupport::TestCase end test "nested number as key" do - params = ActionController::Parameters.new( product: { + params = ActionController::Parameters.new( + product: { properties: { "0" => "prop0", "1" => "prop1" diff --git a/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb index bcb16eaf89..8fab7b28e9 100644 --- a/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb +++ b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb @@ -11,7 +11,8 @@ class RaiseOnUnpermittedParamsTest < ActiveSupport::TestCase end test "raises on unexpected params" do - params = ActionController::Parameters.new( book: { pages: 65 }, + params = ActionController::Parameters.new( + book: { pages: 65 }, fishing: "Turnips") assert_raises(ActionController::UnpermittedParameters) do @@ -20,7 +21,8 @@ class RaiseOnUnpermittedParamsTest < ActiveSupport::TestCase end test "raises on unexpected nested params" do - params = ActionController::Parameters.new( book: { pages: 65, title: "Green Cats and where to find then." }) + params = ActionController::Parameters.new( + book: { pages: 65, title: "Green Cats and where to find then." }) assert_raises(ActionController::UnpermittedParameters) do params.permit(book: [:pages]) diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 05293dd94c..9f0e3bff15 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -29,7 +29,8 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase def test_route_generation_escapes_unsafe_path_characters assert_equal "/content/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2", - url_for(@set, controller: "content", + url_for(@set, + controller: "content", action: "act#{@segment}ion", variable: "var#{@segment}iable", additional: ["add#{@segment}itional-1", "add#{@segment}itional-2"]) @@ -45,7 +46,8 @@ class UriReservedCharactersRoutingTest < ActiveSupport::TestCase def test_route_generation_allows_passing_non_string_values_to_generated_helper assert_equal "/content/action/variable/1/2", - url_for(@set, controller: "content", + url_for(@set, + controller: "content", action: "action", variable: "variable", additional: [1, 2]) @@ -776,7 +778,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end end - assert_equal "/journal", url_for(rs, controller: "content", + assert_equal "/journal", url_for(rs, + controller: "content", action: "list_journal", date: nil, user_id: nil) diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index cce5c2ae37..886cf857e8 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -50,7 +50,8 @@ module ActionDispatch path = Path::Pattern.from_string "/:controller/*extra" route = Route.build("name", nil, path, {}, [], controller: "foo", action: "bar") - assert_equal "/foo/himom", route.format( controller: "foo", + assert_equal "/foo/himom", route.format( + controller: "foo", extra: "himom") end @@ -58,7 +59,8 @@ module ActionDispatch path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))" route = Route.build("name", nil, path, {action: "bar"}, [], controller: "foo") - assert_equal "/foo/bar/10", route.format( controller: "foo", + assert_equal "/foo/bar/10", route.format( + controller: "foo", action: "bar", id: 10) end |