aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | Fix AC::Parameters#to_unsafe_h to return all unfiltered valuesPrathamesh Sonpatki2015-12-311-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - AC::Parameters#convert_parameters_to_hashes should return filtered or unfiltered values based on whether it is called from `to_h` or `to_unsafe_h` instead of always defaulting to `to_h`. - Fixes #22841
* | | | | Merge pull request #22826 from timrogers/actiondispatch-ssl-configRafael França2015-12-311-15/+30
|\ \ \ \ \ | | | | | | | | | | | | Configurable redirect and secure cookies for ActionDispatch::SSL
| * | | | | Flexible configuration for ActionDispatch::SSLTim Rogers2015-12-291-15/+30
| | |_|_|/ | |/| | |
* | | | | Fix test for AC::Parameters#to_unsafe_hPrathamesh Sonpatki2015-12-301-2/+2
| |/ / / |/| | | | | | | | | | | - Test should call `to_unsafe_h` instead of `to_h`
* | | | Merge pull request #22830 from jcoyne/parameters_includeRichard Schneeman2015-12-291-0/+6
|\ \ \ \ | | | | | | | | | | Add AC::Parameters#include?
| * | | | Add AC::Parameters#include?Justin Coyne2015-12-291-0/+6
| |/ / / | | | | | | | | | | | | Fixes #22818
* | | | 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
* | | Currectly test the Middleware#==Rafael Mendonça França2015-12-221-4/+8
| | |
* | | Add #== back to ActionDispatch::MiddlewareStack::MiddlewareJon Moss2015-12-211-0/+12
| |/ |/| | | | | | | This was causing bug #22738 to occur. Also added extra tests to make sure everything is A-OK.
* | Merge pull request #22650 from derekprior/dp-actionpack-warningsRafael França2015-12-181-0/+5
|\ \ | | | | | | Fix "instance variable not initialized" in tests
| * | Fix "instance variable not initialized" in testsDerek Prior2015-12-171-0/+5
| | | | | | | | | | | | | | | | | | | | | The ActionPack test suite had a handful of these warnings when run. This was due to `assert_response` being tested outside the context of a controller instance where those instance variables would already have been initialized.
* | | Merge pull request #20797 from byroot/prevent-url-for-ac-parametersRafael França2015-12-183-3/+10
|\ \ \ | |/ / |/| | Prevent ActionController::Parameters in url_for
| * | Prevent ActionController::Parameters from being passed to url_for directlyJean Boussier2015-12-153-3/+10
| | |
* | | Only dup Ruby's Hash and Array.Kasper Timm Hansen2015-12-171-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | When calling `to_h` on an `ActionController::Parameters` instance it would `deep_dup` its internal parameters. This inadvertently called `dup` on a passed Active Record model which would create new models. Fix by only dupping Ruby's Arrays and Hashes.
* | | Deprecate `redirect_to :back`Derek Prior2015-12-161-2/+15
| | | | | | | | | | | | | | | | | | | | | Applications that use `redirect_to :back` can be forced to 500 by clients that do not send the HTTP `Referer` (sic) header. `redirect_back` requires the user to consider this possibility up front and avoids this trivially-caused application error.
* | | Add `redirect_back` for safer referrer redirectsDerek Prior2015-12-161-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `redirect_to :back` is a somewhat common pattern in Rails apps, but it is not completely safe. There are a number of circumstances where HTTP referrer information is not available on the request. This happens often with bot traffic and occasionally to user traffic depending on browser security settings. When there is no referrer available on the request, `redirect_to :back` will raise `ActionController::RedirectBackError`, usually resulting in an application error. `redirect_back` takes a required `fallback_location` keyword argument that specifies the redirect when the referrer information is not available. This prevents 500 errors caused by `ActionController::RedirectBackError`.
* | | deletes code commented out in 72160d9fTony Ta2015-12-151-10/+0
| | |
* | | Merge pull request #14212 from tylerhunt/fix-token-regexSean Griffin2015-12-151-0/+8
|\ \ \ | | | | | | | | | | | | Handle tab in token authentication header.
| * | | Handle tab in token authentication header.Tyler Hunt2014-02-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HTTP spec allows for LWS to precede the header content, which could include multiple SP and HT characters. Update the regex used to match the Token authorization header to account for this, instead of matching on a single SP. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html and http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html for the relevant parts of the specification.
* | | | Add fragment_cache_key macro for controller-wide fragment cache key prefixesSam Stephenson2015-12-141-0/+25
| | | |
* | | | Merge pull request #22564 from maximeg/legit_name_errorsSean Griffin2015-12-141-0/+41
|\ \ \ \ | | | | | | | | | | Don't catch all NameError to reraise as ActionController::RoutingError
| * | | | Don't catch all NameError to reraise as ActionController::RoutingError #22368Maxime Garcia2015-12-121-0/+41
| | |/ / | |/| |
* / | | Make Parameters#to_h and #to_unsafe_h return HWIAPrem Sichanugrist2015-12-141-4/+4
|/ / / | | | | | | | | | | | | | | | | | | This makes these two methods to be more inline with the previous behavior of Parameters as Parameters used to be inherited from HWIA. Fixes #21391
* | | Show redirect response code in assert_response messagesJon Atack2015-12-111-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up to PR #19977, which helpfully added the redirection path to the error message of assert_response if response is a redirection, but which removed the response code, obscuring the type of redirect. This PR: - brings back the response code in the error message, - updates the tests so the new messages can be tested, - and adds test cases for the change.
* | | Merge pull request #22514 from ↵Rafael França2015-12-111-2/+2
|\ \ \ | | | | | | | | | | | | | | | | prathamesh-sonpatki/use-assert-over-assert-predicate Use assert over assert_predicate in assert_response
| * | | Use assert over assert_predicate in assert_responsePrathamesh Sonpatki2015-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `assert_predicate` appends its own error message at the end of message generated by `assert_response` and because of that the error message displays the whole `response` object. - For eg. Expected response to be a <success>, but was a redirect to <http://test.host/posts>. Expected #<ActionDispatch::TestResponse:0x007fb1cc1cf6f8....(lambda)>}>> to be successful?. - Complete message can be found here - https://gist.github.com/prathamesh-sonpatki/055afb74b66108e71ded#file-gistfile1-txt-L19. - After this change the message from `assert_predicate` won't be displayed and only message generated by `assert_response` will be shown as follows: Expected response to be a <success>, but was a redirect to <http://test.host/posts>
* | | | Merge pull request #20831 from jmbejar/rails-api-json-error-responseSantiago Pastorino2015-12-093-5/+90
|\ \ \ \ | | | | | | | | | | Rails API: Ability to return error responses in json format also in development
| * | | | Do not add format key to request_paramsJorge Bejar2015-12-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I did this change but it is affecting how the request params end up after being processed by the router. To be in the safe side, I just take the format from the extension in the URL when is not present in those params and it's being used only for the `Request#formats` method
| * | | | DebugException initialize with a response_format valueJorge Bejar2015-12-091-2/+2
| | | | |
| * | | | Fix some edge cases in AD::DebugExceptions in rails api appsJorge Bejar2015-12-091-11/+62
| | | | |
| * | | | Response when error should be formatted properly in Rails API if local requestJorge Bejar2015-12-093-4/+25
| | | | |
| * | | | Use URL path extension as format in bad params exception handlingJorge Bejar2015-12-081-1/+15
| | | | |
* | | | | Fix `make_response!` when called by `serve` in `RouteSet`eileencodes2015-12-091-0/+39
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All of our tests were testing the `ActionController::Live` behavior in a standalone environment, without going through the router or behaving like a real application. This resulted in `ActionController::Live` throwing the exception `undefined method 'request' for #<ActionDispatch::Request:0x00000003ad1148>` because `make_response!` was expecting a response instead of a request. The expectation of a response came from `set_response!` in non-router tests setting the response and passing it to `make_response!`. In the case of an application we would hit `serve` in `RouteSet` first which would send us to `make_response!` with a request sent instead of a response. The changes here remove `set_response!` so `make_response!` always receives a request. Thanks to KalabiYau for help with the investigation and solution. Fixes #22524 [Eileen M. Uchitelle & KalabiYau]
* | | | Change the `protect_from_forgery` prepend default to `false`eileencodes2015-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per this comment https://github.com/rails/rails/pull/18334#issuecomment-69234050 we want `protect_from_forgery` to default to `prepend: false`. `protect_from_forgery` will now be insterted into the callback chain at the point it is called in your application. This is useful for cases where you want to `protect_from_forgery` after you perform required authentication callbacks or other callbacks that are required to run after forgery protection. If you want `protect_from_forgery` callbacks to always run first, regardless of position they are called in your application, then you can add `prepend: true` to your `protect_from_forgery` call. Example: ```ruby protect_from_forgery prepend: true ```
* | | | Push `before_sending` to super classeileencodes2015-12-066-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* | | | Merge pull request #22453 from wjessop/use_action_dispatch_default_tld_lengthEileen M. Uchitelle2015-12-061-26/+30
|\ \ \ \ | |/ / / |/| | | Test against the real value of tld_length unless explicitly set
| * | | 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.
* | | | Add redirection path in the error message of assert_response if response is ↵Prathamesh Sonpatki2015-12-041-1/+16
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | :redirect - If the assert_response is checking for any non-redirect response like :success and actual response is :redirect then, the error message displayed was - Expected response to be a <success>, but was <302> - This commit adds the redirect path to the error message of assert_response if the response is :redirect. So above message is changed to - Expected response to be a <success>, but was a redirect to <http://test.host/posts/lol>
* | | Merge pull request #22371 from yui-knk/better_mount_errorArthur Nogueira Neves2015-11-281-1/+13
|\ \ \ | | | | | | | | Brush up errors of `ActionDispatch::Routing::Mapper#mount`
| * | | Brush up errors of `ActionDispatch::Routing::Mapper#mount`yui-knk2015-11-281-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | * Integrate to raise `ArgumentError` * Detailed error message when `path` is not defined * Add a test case, invalid rack app is passed
* | | | Merge pull request #21241 from pdg137/masterArthur Nogueira Neves2015-11-261-0/+7
|\ \ \ \ | | | | | | | | | | In url_for, never append ? when the query string is empty anyway.
| * | | | In url_for, never append ? when the query string is empty anyway.Paul Grayson2015-10-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It used to behave like this: url_for(controller: 'x', action: 'y', q: {}) # -> "/x/y?" We previously avoided empty query strings in most cases by removing nil values, then checking whether params was empty. But as you can see above, even non-empty params can yield an empty query string. So I changed the code to just directly check whether the query string ended up empty. (To make everything more consistent, the "removing nil values" functionality should probably move to ActionPack's Hash#to_query, the place where empty hashes and arrays get removed. However, this would change a lot more behavior.)
* | | | | Merge pull request #22263 from mastahyeti/csrf-origin-checkRafael França2015-11-261-0/+45
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Add option to verify Origin header in CSRF checks [Jeremy Daer + Rafael Mendonça França]
| * | | | | Add option to verify Origin header in CSRF checksBen Toews2015-11-251-0/+45
| | | | | |
* | | | | | Merge pull request #22172 from tijmenb/fix-source-in-show-exceptionRafael França2015-11-241-0/+8
|\ \ \ \ \ \ | | | | | | | | | | | | | | Add text template for source code
| * | | | | | Add text template for source codeTijmen Brommet2015-11-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a request is made with AJAX and an error occurs, Rails will render a text-template for the exception instead of the HTML error page (#11960). The `.text.erb` variant of the `_source` template is currently missing, causing HTML to be rendered in the response. This commit adds the text template. To keep the page scannable we only only show the first three source extracts. Related to #14745. Before: ``` ~/testing-exceptions ᐅ curl 'http://localhost:3000/' -H 'X-Requested-With: XMLHttpRequest' RuntimeError in PostsController#index <div class="source " id="frame-source-0"> <div class="info"> Extracted source (around line <strong>#3</strong>): </div> <div class="data"> <table cellpadding="0" cellspacing="0" class="lines"> <tr> ``` After: ``` ~/testing-exceptions ᐅ curl 'http://localhost:3000/' -H 'X-Requested-With: XMLHttpRequest' RuntimeError in PostsController#index Extracted source (around line #3): *3 raise ```
* | | | | | | 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.
* | | | | | | Remove arity check for `RouteSet#draw`yui-knk2015-11-211-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code was added for migration from Rails 3.1 to upper, now we are developing Rails 5.