diff options
author | eileencodes <eileencodes@gmail.com> | 2017-08-01 15:10:51 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-08-01 15:10:51 -0400 |
commit | 789f3be02048cf33c14c8a98c6fe91d0d7b157eb (patch) | |
tree | 2d7c8e28c03d83d6c15560048d4d4697f33d2f90 /actionpack | |
parent | 9e3d8cbd0705cacf424ef4f99d2e317168442065 (diff) | |
download | rails-789f3be02048cf33c14c8a98c6fe91d0d7b157eb.tar.gz rails-789f3be02048cf33c14c8a98c6fe91d0d7b157eb.tar.bz2 rails-789f3be02048cf33c14c8a98c6fe91d0d7b157eb.zip |
Clarify route encoding test
Since this test changed in 9220935 I noticed that it really doesn't make
sense anymore. I split the tests into 2 groups to explain what each one
does.
First these routes should throw a `bad_request` when the encoding isn't
valid. We're expecting UTF8 encoding and passing binary, that should be
a bad request.
For the second test we are setting the `show` route to set
`self.binary_params_for?` for that route which will convert the
parameters and return a `:ok` instead of a `:bad_request`.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 2bb814e5f4..446b65a9b9 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -4425,17 +4425,15 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest end end - test "invalid UTF-8 encoding is treated as ASCII 8BIT encode" do + test "invalid UTF-8 encoding returns a bad request" do with_routing do |set| set.draw do get "/bar/:id", to: redirect("/foo/show/%{id}") - get "/foo/show(/:id)", to: "test_invalid_urls/foo#show" ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] } get "/foobar/:id", to: ok ActiveSupport::Deprecation.silence do - get "/foo(/:action(/:id))", controller: "test_invalid_urls/foo" get "/:controller(/:action(/:id))" end end @@ -4446,9 +4444,6 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest get "/foo/%E2%EF%BF%BD%A6" assert_response :bad_request - get "/foo/show/%E2%EF%BF%BD%A6" - assert_response :ok - get "/bar/%E2%EF%BF%BD%A6" assert_response :bad_request @@ -4456,6 +4451,17 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest assert_response :bad_request end end + + test "params encoded with binary_params_for? are treated as ASCII 8bit" do + with_routing do |set| + set.draw do + get "/foo/show(/:id)", to: "test_invalid_urls/foo#show" + end + + get "/foo/show/%E2%EF%BF%BD%A6" + assert_response :ok + end + end end class TestOptionalRootSegments < ActionDispatch::IntegrationTest |