diff options
Diffstat (limited to 'actionpack/test/controller/integration_test.rb')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 652c0f0dd2..4fae4071b1 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -145,7 +145,7 @@ class IntegrationTestTest < ActiveSupport::TestCase name.to_s == "foo" ? "pass" : super end end - @test.class.superclass.__send__(:include, mixin) + @test.class.superclass.include(mixin) begin assert_equal "pass", @test.foo ensure @@ -153,14 +153,6 @@ class IntegrationTestTest < ActiveSupport::TestCase mixin.__send__(:remove_method, :method_missing) end end - - def test_assigns_is_undefined_and_not_point_to_the_gem - e = assert_raises(NoMethodError) do - @test.assigns(:foo) - end - - assert_match(/undefined method/, e.message) - end end # Tests that integration tests don't call Controller test methods for processing. @@ -281,7 +273,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest self.cookies["cookie_2"] = "oatmeal" get "/cookie_monster" assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"] - assert_equal({ "cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate" }, cookies.to_hash) + assert_equal({ "cookie_1" => "", "cookie_2" => "oatmeal", "cookie_3" => "chocolate" }, cookies.to_hash) end end @@ -291,14 +283,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest assert_response :success assert_equal "foo=bar; path=/", headers["Set-Cookie"] - assert_equal({ "foo"=>"bar" }, cookies.to_hash) + assert_equal({ "foo" => "bar" }, cookies.to_hash) get "/get_cookie" assert_response :success assert_equal "bar", body - assert_equal nil, headers["Set-Cookie"] - assert_equal({ "foo"=>"bar" }, cookies.to_hash) + assert_nil headers["Set-Cookie"] + assert_equal({ "foo" => "bar" }, cookies.to_hash) end end @@ -310,14 +302,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest assert_response :success assert_equal "foo=bar; path=/", headers["Set-Cookie"] - assert_equal({ "foo"=>"bar" }, cookies.to_hash) + assert_equal({ "foo" => "bar" }, cookies.to_hash) get "/get_cookie" assert_response :success assert_equal "bar", body - assert_equal nil, headers["Set-Cookie"] - assert_equal({ "foo"=>"bar" }, cookies.to_hash) + assert_nil headers["Set-Cookie"] + assert_equal({ "foo" => "bar" }, cookies.to_hash) end end @@ -364,6 +356,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest end end + test "creation of multiple integration sessions" do + integration_session # initialize first session + a = open_session + b = open_session + + refute_same(a.integration_session, b.integration_session) + end + def test_get_with_query_string with_test_route_set do get "/get_with_params?foo=bar" @@ -924,12 +924,16 @@ class IntegrationRequestsWithSessionSetup < ActionDispatch::IntegrationTest def test_cookies_set_in_setup_are_persisted_through_the_session get "/foo" - assert_equal({ "user_name"=>"david" }, cookies.to_hash) + assert_equal({ "user_name" => "david" }, cookies.to_hash) end end class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest class FooController < ActionController::Base + def foos + render plain: "ok" + end + def foos_json render json: params.permit(:foo) end @@ -958,13 +962,30 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest def test_encoding_as_json post_to_foos as: :json do assert_response :success - assert_match "foos_json.json", request.path assert_equal "application/json", request.content_type + assert_equal "application/json", request.accepts.first.to_s + assert_equal :json, request.format.ref assert_equal({ "foo" => "fighters" }, request.request_parameters) assert_equal({ "foo" => "fighters" }, response.parsed_body) end end + def test_doesnt_mangle_request_path + with_routing do |routes| + routes.draw do + ActiveSupport::Deprecation.silence do + post ":action" => FooController + end + end + + post "/foos" + assert_equal "/foos", request.path + + post "/foos_json", as: :json + assert_equal "/foos_json", request.path + end + end + def test_encoding_as_without_mime_registration assert_raise ArgumentError do ActionDispatch::IntegrationTest.register_encoder :wibble @@ -979,8 +1000,10 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest post_to_foos as: :wibble do assert_response :success - assert_match "foos_wibble.wibble", request.path + assert_equal "/foos_wibble", request.path assert_equal "text/wibble", request.content_type + assert_equal "text/wibble", request.accepts.first.to_s + assert_equal :wibble, request.format.ref assert_equal Hash.new, request.request_parameters # Unregistered MIME Type can't be parsed. assert_equal "ok", response.parsed_body end @@ -1078,8 +1101,8 @@ class IntegrationFileUploadTest < ActionDispatch::IntegrationTest def test_fixture_file_upload post "/test_file_upload", params: { - file: fixture_file_upload("/mona_lisa.jpg", "image/jpg") + file: fixture_file_upload("/ruby_on_rails.jpg", "image/jpg") } - assert_equal "159528", @response.body + assert_equal "45142", @response.body end end |