| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
| |
At GitHub we need to handle parameter encodings that are not UTF-8. This
patch allows us to specify encodings per parameter per action.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In integration test when specify the "Accept" header with "xhr: true"
option, the Accept header is overridden with a default xhr Accept
header. The issue only affects HTTP header "Accept" but not CGI variable
"HTTP_ACCEPT".
For example:
get '/page', headers: { 'Accept' => 'application/json' }, xhr: true
# This is WRONG! And the response.content_type is also affected.
# It should be "application/json"
assert_equal "text/javascript, text/html, ...", request.accept
assert_equal 'text/html', response.content_type
The issue is in `ActionDispatch::Integration::RequestHelpers`. When
setting "xhr: true" the helper sets a default HTTP_ACCEPT if blank.
But the code doesn't consider supporting both HTTP header style and
CGI variable style.
For detail see this GitHub issue:
https://github.com/rails/rails/issues/25859
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a `GET` request is sent `as: :json` in an integration test the test
should use Rack's method override to change to a post request so the
paramters are included in the postdata. Otherwise it will not encode the
parameters correctly for the integration test.
Because integration test sets up it's own middleware,
`Rack::MethodOverride` needs to be included in the integration tests as
well.
`headers ||= {}` was moved so that headers are never nil. They should
default to a hash.
Fixes #26033
[Eileen M. Uchitelle & Aaron Patterson]
|
| |
|
|
|
|
| |
Fixes #25926
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we'd only assign a response parser when a request came through
Action Dispatch integration tests. This made calls to `parsed_body` when a TestResponse
was manually instantiated — though own doing or perhaps from a framework — unintentionally
blow up because no parser was set at that time.
The response can lookup a parser entirely through its own ivars. Extract request encoder to
its own file and assume that a viable content type is present at TestResponse instantiation.
Since the default response parser is a no-op, making `parsed_body` equal to `body`, no
exceptions will be thrown.
|
| |
|
|
|
|
|
|
| |
Felt that += overwriting the path variable was a little too hidden.
Make the outcomes easier to spot with an if-else branch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When running tests with `--enable-frozen-string-literal` or
`# frozen_string_literal: true`, it's currently attempted to mutate the path
string in order to append the format, causing a `RuntimeError`.
```ruby
get '/posts', as: :json
```
```
RuntimeError:
can't modify frozen String
```
This commit fixes the problem by replacing the mutation with a concatenation,
returning a new string.
|
|
|
|
| |
Then just yield the location for the place where we need some extra processing.
|
|
|
|
| |
`if !var.nil?` is the same as just `if var`
|
|
|
|
|
|
|
|
| |
Currently, if path is a relative path, add format without the discrimination of the query.
Therefore, if there is a query, format at end of the query would been added,
format was not be specified correctly.
This fix add format to end of path rather than query.
|
|
|
|
| |
Follow up to #21671
|
|
|
|
|
|
|
|
| |
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005
* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
|
|
|
|
|
|
|
|
|
| |
Last August (2015), @tenderlove worked to remove all `@env[]` and `@env[]=`, in
favor of using `set_header`, `get_header`, etc. (Here's an [example
commit](https://github.com/rails/rails/commit/f16a33b68efc3dc57cfafa27651b9a765e363fbf)).
This PR should remove the last uses of these methods, and fully convert
them to the newly standardized API.
|
|
|
|
|
|
|
|
| |
- Followup of https://github.com/rails/rails/issues/18693.
- I think we missed deprecating `request_via_redirect` in that pull
request.
- Originally requested by DHH here
https://github.com/rails/rails/issues/18333.
|
|
|
|
|
|
|
|
|
|
| |
- we are ending sentences properly
- fixing of space issues
- fixed continuity issues in some sentences.
Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 .
This change reverts making sure we add '.' at end of deprecation sentences.
This is to keep sentences within Rails itself consistent and with a '.' at the end.
|
|
|
|
|
| |
Similar to 176fbfd6, this makes it possible for other test
frameworks to hook into Rails integration test facilities.
|
|
|
|
|
|
|
|
|
|
| |
After 9d378747326d26cf1afdac4433ead22967af0984 `ActionDispatch::IntegrationTest`
class is loaded and defined in all Rails environments, not only test but also
production. This is not-intended loading of a class which is only used in
test environment.
To prevent not-intended loading, add `ActiveSupport.run_load_hooks` to
`ActionDispatch::IntegrationTest` with `action_dispatch_integration_test` name
and use it in `ActionMailer`.
|
| |
|
|
|
|
|
|
|
|
| |
This reverts changes made to integration tests in PR #23807.
The issue happens when using capybara with a driver that needs to start a
server in a separate thread like (poltergeist, selenium, etc).
Both threads the capybara server one and the test thread end running
syncronize over the interlock.
|
|
|
|
|
|
| |
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Yesterday, when improving how `parsed_body` extracted a parser I wrote
77bbf1e. Then I thought that was too many changes in one commit
and broke it up locally... or so I thought.
When pushed the extra commits removed the changes! Wups!
In shame, lob those changes together here:
* 3b94c38 which meant to fix the CHANGELOG syntax error.
* 5007df5 which meant to mention `parsed_body` in the docs.
* 036a7a0 which meant to memoize the `parsed_body`.
|
|
|
|
|
|
|
|
| |
It's common to use several assertions on the parsed response. The response
bodies aren't meant to be mutated. People should make new test requests
instead.
Thus, it should be safe to memoize the parsing.
|
|
|
|
| |
Little easier to understand when you know the method that's used.
|
|
|
|
|
|
|
| |
We're not guaranteed to have a `RequestEncoder` to assign on `get` requests
because we aren't extracting the parser from the response content type.
Until now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When testing:
```ruby
post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json
```
It's common to want to make assertions on the response body. Perhaps the
server responded with JSON, so you write `JSON.parse(response.body)`.
But that gets tedious real quick.
Instead add `parsed_body` which will automatically parse the reponse
body as what the last request was encoded `as`.
|
|\
| |
| | |
Add `as` to encode a request as a specific mime type.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Turns
```
post articles_path(format: :json), params: { article: { name: 'Ahoy!' } }.to_json,
headers: { 'Content-Type' => 'application/json' }
```
into
```
post articles_path, params: { article: { name: 'Ahoy!' } }, as: :json
```
|
| |
| |
| |
| |
| | |
Prototype, you have served us well. But you are no longer how we make an
XMLHttpRequest. RIP
|
| | |
|
| |
| |
| |
| | |
`with_indifferent_access` had been used in `assigns` method, but has been removed in ca83436.
|
|/
|
|
|
| |
Also, refactor logic to convert between symbol and response code,
via the AssertionResponse class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Rails 5.1 `ActionController::TestCase` will be moved out of Rails
into it's own gem.
Please use `ActionDispatch::IntegrationTest` going foward.
Because this will be moved to a gem I used `# :stopdoc:` instead of
deleting the documentation. This will remove it from the Rails
documentation but still leave the method documented for when we move it
to a gem.
Guides have been updated to use the routing structure used in Integration
and all test examples have been updated to inherit from
`ActionDispatch::IntegrationTest` instead of `ActionController::TestCase.
Fixes #22496
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| |
| |
| | |
prathamesh-sonpatki/use-assert-over-assert-predicate
Use assert over assert_predicate in assert_response
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- `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>
|
|/
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
: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>
|
| |
|
|\ |
|
| |
| |
| |
| |
| | |
‘Asserts’ at all places [ci skip]
Following commit https://github.com/rails/docrails/commit/495722a95687e25114ae75608dd3107ac5d6611b
|
| | |
|
| |
| |
| |
| | |
`skip_filter`, `skip_action_callback` may both are deprecated in Rails 5.1 so waring msg should be specific.
|
| |
| |
| |
| |
| |
| | |
This commit follows up of ea9bc06c9a47b839d5e2db94ba6bf7e29c8f0ae9.
To check `@response.content_type.to_s` is ended with `"xml"`,
to use `\z` is sufficient.
|
| |
| |
| |
| | |
parse RSS/ATOM responses as XML, not HTML
|