aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql/sp_test.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-09-08 11:43:10 -0400
committereileencodes <eileencodes@gmail.com>2015-09-09 09:04:44 -0400
commit43d7a03aef737787d4166fe347f40d901f6334c3 (patch)
tree795ea027cc6bd51f77dee78211ad314114c69684 /activerecord/test/cases/adapters/mysql/sp_test.rb
parentd73d1a26b342b2323a58b55021eb8701790ada2a (diff)
downloadrails-43d7a03aef737787d4166fe347f40d901f6334c3.tar.gz
rails-43d7a03aef737787d4166fe347f40d901f6334c3.tar.bz2
rails-43d7a03aef737787d4166fe347f40d901f6334c3.zip
Handle Content-Types that are not :json, :xml, or :url_encoded_form
In c546a2b this was changed to mimic how the browser behaves in a real situation but left out types that were registered. When this was changed it didn't take `text/plain` or `text/html` content types into account. This is a problem if you're manipulating the `Content-Type` headers in your controller tests, and expect a certain result. The reason I changed this to use `to_sym` is because if the `Content-Type` is not registered then the symbol will not exist. If it's one of the special types we handle that specifically (:json, :xml, or :url_encoded_form). If it's any registered type we handle it by setting the `path_parameters` and then the `request_parameters`. If the `to_sym` returns nil an error will be thrown. If the controller test sets a `Content-Type` on the request that `Content-Type` should remain in the header and pass along the filename. For example: If a test sets a content type on a post ``` @request.headers['CONTENT_TYPE'] = 'text/plain' post :create, params: { name: 'foo.txt' } ``` Then `foo.txt` should be in the `request_parameters` and params related to the path should be in the `path_parameters` and the `Content-Type` header should match the one set in the `@request`. When c546a2b was committed `text/plain` and `text/html` types were throwing a "Unknown Content-Type" error which is misleading and incorrect. Note: this does not affect how this is handled in the browser, just how the controller tests handle setting `Content-Type`.
Diffstat (limited to 'activerecord/test/cases/adapters/mysql/sp_test.rb')
0 files changed, 0 insertions, 0 deletions