aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Document and test ActionDispatch server_portTom Kadwill2016-05-121-0/+11
|
* Improve documentation and tests for raw_host_with_port and host_with_portTom Kadwill2016-05-111-0/+20
|
* Strong ETag validatorsJeremy Daer2016-03-311-15/+20
| | | | | | | | | | | | | | | | | | * Introduce `Response#strong_etag=` and `#weak_etag=` and analogous options for `fresh_when` and `stale?`. `Response#etag=` sets a weak ETag. Strong ETags are desirable when you're serving byte-for-byte identical responses that support Range requests, like PDFs or videos (typically done by reproxying the response from a backend storage service). Also desirable when fronted by some CDNs that support strong ETags only, like Akamai. * No longer strips quotes (`"`) from ETag values before comparing them. Quotes are significant, part of the ETag. A quoted ETag and an unquoted one are not the same entity. * Support `If-None-Match: *`. Rarely useful for GET requests; meant to provide some optimistic concurrency control for PUT requests.
* Format from Accept headers have higher precedence than path extension formatJorge Bejar2015-12-291-0/+9
|
* Rely on default Mime format when MimeNegotiation#format_from_path_extension ↵Jorge Bejar2015-12-291-0/+12
| | | | | | is not a valid type Closes #22747
* Test against the real value of tld_length unless explicitly setWill Jessop2015-12-041-26/+30
| | | | | | | | | | | There were two places where the tld_length default was hard-coded to 1, both overriding the real default value of ActionDispatch::Http::URL.tld_length in this set of tests. This commit removes both of those, relying on the actual value of ActionDispatch::Http::URL.tld_length, unless it's specifically overridden.
* Merge pull request #17928 from sergey-alekseev/remove-unused-form-data-methodSean Griffin2015-11-231-0/+20
|\
| * write a test for `#form_data?`Sergey Alekseev2015-03-311-0/+20
| | | | | | | | | | | | | | | | | | The initial attempt was to remove the method at all in https://github.com/sergey-alekseev/rails/commit/4926aa68c98673e7be88a2d2b57d72dc490bc71c. The method overrides Rack's `#form_data?` https://github.com/rack/rack/blob/6f8808d4201e68e4bd780441b3b7bb3ee6d1f43e/lib/rack/request.rb#L172-L184. Which may have some incorrect implementation actually. `type.nil?` isn't possible I suppose. I'll check.
* | Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-2/+2
| |
* | Catch invalid UTF-8 querystring values and respond with BadRequestGrey Baker2015-10-231-6/+10
| |
* | Show helpful messages on invalid param. encodingsAgis Anastasopoulos2015-10-191-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, given a route: # config/routes.rb get ':a' => "foo#bar" If one pointed to http://example.com/%BE (param `a` has invalid encoding), a `BadRequest` would be raised with the following non-informative message: ActionController::BadRequest From now on the message displayed is: Invalid parameter encoding: hi => "\xBE" Fixes #21923.
* | Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
* | stop calling deprecated methodsAaron Patterson2015-09-211-24/+24
| | | | | | | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* | Remove mocha from ActionPack testsMarcin Olichwirowicz2015-09-051-41/+61
| |
* | Allow filtering params based on parent keysGuillaume Malette2015-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | Add the possibility to only filter parameters based on their full path instead of relying on the immediate key. config.filter_parameters += ['credit_card.code'] { 'credit_card' => { 'code' => '[FILTERED]' }, 'source' => { 'code' => '<%= puts 5 %>' } }
* | Add assertion for get? method into test casesMehmet Emin İNAÇ2015-05-271-0/+1
|/
* Define a setup method instead of using setup as blockRafael Mendonça França2015-03-271-1/+2
| | | | | setup as block run before setup actlually runs so it will fail for our case
* Provide friendlier access to request variantsGeorge Claghorn2015-03-241-19/+30
| | | | Closes #18933.
* Fix handling of empty X_FORWARDED_HOST header.adam2015-03-201-0/+3
| | | | | | Previously, an empty X_FORWARDED_HOST header would cause Actiondispatch::Http:URL.raw_host_with_port to return nil, causing Actiondispatch::Http:URL.host to raise a NoMethodError.
* allow reseting of request variantsTimo Schilling2014-12-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | The current implementation of `variants=` don't allow a resetting to nil, wich is the default value. This results in the following code smell: ```ruby case request.user_agent when /iPhone/ request.variants = :phone when /iPad/ request.variants = :ipad end ``` With the ability to reset variants to nil, it could be: ```ruby request.variants = case request.user_agent when /iPhone/ :phone when /iPad/ :ipad end ```
* ParameterFilter shouldn't try to dup symbol keysNate Berkopec2014-12-131-2/+2
|
* Request#check_method no longer breaks when :en is not available localeStefan Henzen2014-10-091-0/+16
| | | | | | | | Request#check_method would use to_sentence(locale: :en), which breaks when I18n.available_locales does not include :en and I18n.enforce_available_locales is true (default). Inlined to_sentence functionality to solve this.
* Rescue Rack::Utils::ParameterTypeError instead of TypeErrorYuki Nishijima2014-09-131-3/+3
| | | | | | | | As of rack/rack@167b6480235ff00ed5f355698bf00ec2f250f72e, Rack raises Rack::Utils::ParameterTypeError which inherits TypeError. In terms of the behavior, Rescuing TypeError still works but this method shouldn't rescue if TypeError is raised for other reasons.
* Avoid duplicating routes for HEAD requests.Guo Xiang Tan2014-08-211-0/+12
| | | | | | | | Follow up to rails#15321 Instead of duplicating the routes, we will first match the HEAD request to HEAD routes. If no match is found, we will then map the HEAD request to GET routes.
* Protect against error when parsing parameters with Bad RequestRafael Mendonça França2014-08-191-0/+25
| | | | Related with #11795.
* [ci skip] fix spelling of overrideAkshay Vishnoi2014-08-131-1/+1
|
* Merge pull request #16098 from tgxworld/fixes_to_request_testRafael Mendonça França2014-07-181-22/+14
|\ | | | | Fixes to request method test.
| * Remove redundant test.Guo Xiang Tan2014-07-181-11/+0
| | | | | | | | | | | | | | | | Since we're stubbing the request, the test is actually just asserting that `@method = env['REQUEST_METHOD']`. In order to the test against the methodoverride middleware, we should test it against an actual request. However, Rack is already covering this scenario so we can remove this test.
| * Fix duplicated test.Guo Xiang Tan2014-07-181-2/+6
| | | | | | | | | | There is already another test covering Request#request_method. This test should cover Request#method.
| * Update test to clearly reflect what it is testing for.Guo Xiang Tan2014-07-181-5/+7
| |
| * Update outdated test.Guo Xiang Tan2014-07-181-6/+3
| | | | | | | | | | The current test is asserting against an outdated version of Request#method where HEAD requests are treated as GET requests.
* | Add CHANGELOG for #14886Arthur Neves2014-07-181-1/+1
| | | | | | | | | | | | | | Also cleanup test a bit [related #14886] [related #14743]
* | LOCALHOST definition should match any 127.0.0.0/8 addressEarl J St Sauver2014-07-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The entire 127.0.0.0/8 range is assigned to the loopback address, not only 127.0.0.0/24. This patch allows ActionDispatch::Request::LOCALHOST to match any IPv4 127.0.0.0/8 loopback address. The only place that the #local? method was previously under test was in the show_expectations_test.rb file. I don't particularly like that that's implicitly where this code is under test, and I feel like I should move some of that testing code into the test/dispatch/request_test.rb file, but I wanted some feedback first. Credit goes to @sriedel for discovering the issue and adding the patch.
* | Merge pull request #13999 from jamox/update_rackAaron Patterson2014-07-081-6/+12
|\ \ | |/ |/| This updates rails to use edge rack
| * Upgraded rackJarmo Isotalo2014-05-191-6/+12
| | | | | | | | | | | | | | | | As Rack has some non backwards compatible changes added required modifications to keep behaviour in rails close to same as before. Also modified generators to include rack/rack for not yet released version of rack
* | Fix typoRafael Mendonça França2014-07-021-1/+1
| |
* | Avoid hard-coded value in test setup/teardown.Zuhao Wan2014-06-051-1/+2
|/
* Merge pull request #12651 from cespare/ipv6-remote-ip-fixesRafael Mendonça França2014-05-011-1/+4
|\ | | | | | | | | | | | | Make remote_ip detection properly handle private IPv6 addresses Conflicts: actionpack/CHANGELOG.md
| * Make remote_ip detection properly handle private IPv6 addressesCaleb Spare2013-10-261-1/+4
| | | | | | | | Fixes #12638.
* | Refactor tests from BaseRackTest into BaseRequestTestZachary Scott2014-03-011-179/+386
| |
* | Check if variant array contains only symbolsŁukasz Strzałkowski2014-02-131-0/+8
| |
* | Variant negotiationLukasz Strzalkowski2014-02-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow setting `request.variant` as an array - an order in which they will be rendered. For example: request.variant = [:tablet, :phone] respond_to do |format| format.html.none format.html.phone # this gets rendered end
* | Fix assertions for testing unknown formats using Mime::NullTypeCarlos Antonio da Silva2013-12-191-5/+5
| |
* | Action Pack VariantsŁukasz Strzałkowski2013-12-041-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, variants in the templates will be picked up if a variant is set and there's a match. The format will be: app/views/projects/show.html.erb app/views/projects/show.html+tablet.erb app/views/projects/show.html+phone.erb If request.variant = :tablet is set, we'll automatically be rendering the html+tablet template. In the controller, we can also tailer to the variants with this syntax: class ProjectsController < ActionController::Base def show respond_to do |format| format.html do |html| @stars = @project.stars html.tablet { @notifications = @project.notifications } html.phone { @chat_heads = @project.chat_heads } end format.js format.atom end end end The variant itself is nil by default, but can be set in before filters, like so: class ApplicationController < ActionController::Base before_action do if request.user_agent =~ /iPad/ request.variant = :tablet end end end This is modeled loosely on custom mime types, but it's specifically not intended to be used together. If you're going to make a custom mime type, you don't need a variant. Variants are for variations on a single mime types.
* | Add regression test for IpSpoofAttackError issueAlvaro Redondo2013-09-031-0/+8
|/ | | | See #10780
* Fix formats on xhr requests when HTTP_ACCEPT is empty stringmaximerety2013-03-041-0/+5
| | | | | | Fix ActionDispatch::Request#formats on xhr requests when HTTP_ACCEPT header is empty string. About issue #7774, same fix as in commit bebb02f but for xhr requests.
* Merge pull request #8704 from senny/remove_regexp_global_from_url_forAaron Patterson2013-02-141-0/+3
|\ | | | | replace regexp global in #url_for
| * replace regexp global in #url_forYves Senn2013-01-161-0/+3
| |
* | Fix ActionDispatch::Request#formats when HTTP_ACCEPT header is empty stringKonstantin Papkovskiy2013-01-171-0/+4
|/
* adding regression test in master for #8631Aditya Sanghi2013-01-161-0/+21
|