Commit Graph

5846 Commits

Author SHA1 Message Date
Kasper Timm Hansen
b9825801e2 Merge pull request #21321 from rodzyn/removing_mocha
Get rid of mocha tests in actionpack - part 1
2015-08-24 12:44:01 +02:00
Marcin Olichwirowicz
3a161e65e7 Get rid of mocha tests - part 1 2015-08-24 12:24:07 +02:00
akihiro17
7adef79e14 Remove unused variables 2015-08-24 17:33:19 +09:00
Aditya Kapoor
b393c6af92 Trim out unneeded controllers from AP test suite 2015-08-24 01:02:14 +05:30
Aaron Patterson
5fe141638f use a request object in the session middleware
This commit allows us to use one request object rather than allocating
multiple request objects to deal with the session.
2015-08-22 17:57:45 -07:00
eileencodes
4276b214f8 Refactor to remove controller class from route to request
This refactoring moves the controller class name that was on the route
set to the request. The purpose of this refactoring is for changes we
need to move controller tests to integration tests, mainly being able to
access the controller on the request instead of having to go through
the router.

[Eileen M. Uchitelle & Aaron Patterson]
2015-08-22 09:44:24 -04:00
Aaron Patterson
34fa6658dd pass a request object to the headers object 2015-08-21 11:21:10 -07:00
Aaron Patterson
c6cfcc6124 move header allocation to a helper method
I'm going to change the constructor, so it's easier to do it in one
place.
2015-08-21 11:21:10 -07:00
Andrew White
95cb2e3a8a Merge pull request #21106 from amitsuroliya/fix_routing_test
Remove duplicity in tests
2015-08-21 11:25:38 +01:00
Marcin Olichwirowicz
36e53fca78 Add test for parsing application/vnd.api+json 2015-08-21 09:31:18 +02:00
Aaron Patterson
51211a94bd point at rack master 2015-08-20 13:45:11 -07:00
Aaron Patterson
7187339854 make the routes reader private
nobody should be touching the routes hash without going through the
NamedRouteCollection object.
2015-08-18 16:33:18 -07:00
Aaron Patterson
4d9475bef9 symbols will always be constructed with strings. 💣 2015-08-18 15:20:19 -07:00
Aaron Patterson
23cfdd4b71 test the verb method on the route, specifically 2015-08-17 16:36:31 -07:00
Aaron Patterson
c42db41f54 routes are always constructed with a hash for the conditions 2015-08-17 16:30:53 -07:00
Aaron Patterson
1ce74b009f introduce an alternate constructor for Route objects
I want to change the real constructor to take a particular parameter for
matching the request method
2015-08-17 16:08:39 -07:00
Aaron Patterson
e9777ef62e default pattern to use a joined string
The string we create is almost always the same, so rather than joining
all the time, lets join once, then reuse that string everywhere.
2015-08-17 13:51:38 -07:00
Aaron Patterson
703275ba70 use the mapper to build the routing table
We should build the routes using the user facing API which is `Mapper`.
This frees up the library internals to change as we see fit. IOW we
shouldn't be testing internals.
2015-08-15 14:32:04 -07:00
Aaron Patterson
a293812bff only keep one hash of named routes
The outer router object already keeps a hash of named routes, so we
should just use that.
2015-08-14 18:06:48 -07:00
Aaron Patterson
4bdd92d9fd rm add_route2
refactor the tests with a backwards compatible method call so we can rm
add_route2 from the journey router
2015-08-14 16:25:03 -07:00
Aaron Patterson
6c48d9392f pass pass the mapping object down the add_route stack
then we can let the mapping object derive stuff that the Route object
needs.
2015-08-14 16:13:26 -07:00
Aaron Patterson
5ba6966766 pass the mapping object to build_route
now that we aren't doing options manipulations, we can just pass the
mapping object down and read values from it.
2015-08-14 14:41:48 -07:00
Aaron Patterson
b10b279b97 deprecate passing a string for both the beginning path and :path option 2015-08-14 11:55:50 -07:00
Aaron Patterson
b592c5b607 pass the path ast down
now we don't need to add it to a hash and delete it from the hash later
just to pass it around
2015-08-14 10:44:49 -07:00
Aaron Patterson
aaaa67902e pull up path parsing
`add_route` needs the AST, so rather than shove it in a hash and delete
later, lets move parsing up the stack so we can pass down later
2015-08-14 10:39:33 -07:00
Aaron Patterson
7fa6600b52 use predicate methods instead of hard coding verb strings
also change the feeler to subclass AD::Request so that it has all the
methods that Request has
2015-08-14 10:39:33 -07:00
Aaron Patterson
c3284e2a36 implement requirements in terms of routes 2015-08-14 10:39:33 -07:00
Aaron Patterson
60adf118a6 implement the asts method in terms of paths / patterns
Eventually I want to eliminate the FakeSet test class
2015-08-14 10:39:32 -07:00
Aaron Patterson
61437232a9 extract ast finding to a method
I'm going to reimplement this using route objects, so it will be easier
if we just change ast access to go through a method rather than hashes
2015-08-14 10:39:32 -07:00
Aaron Patterson
715abbbb33 stop adding path_info to the conditions hash
we don't need to keep adding it and deleting if from hashes.
2015-08-14 10:39:32 -07:00
Aaron Patterson
947ebe9a6d remove Strexp
This was a useless object.  We can just directly construct a
Path::Pattern object without a Strexp object.
2015-08-13 15:42:46 -07:00
Aaron Patterson
4868692687 pass anchor directly to Pattern
the caller already has it, there is no reason to pack it in to an object
and just throw that object away.
2015-08-13 15:16:25 -07:00
Aaron Patterson
45d594fa53 pull up options_constrants extraction 2015-08-13 14:15:04 -07:00
Aaron Patterson
b778f6348b remove as
the caller already has access to `as`, so we can stop passing it around.
2015-08-13 14:04:02 -07:00
Aaron Patterson
e38a456faf remove anchor from mapping
the same value that is extracted from the options hash earlier is
returned, so we don't need to pass it in in the first place.  The caller
already has the data, so stop passing it around.
2015-08-13 13:58:16 -07:00
Aaron Patterson
aef421ed9d pull anchor extraction up
this way we don't have to mutate the options hash so far away from where
the user passed it in
2015-08-13 13:55:03 -07:00
Aaron Patterson
33dc653466 raise if anchor is passed to scope
The `anchor` parameter [is overridden](b4b4a611d0/actionpack/lib/action_dispatch/routing/mapper.rb (L1528)) unless it
is directly passed to `match`, so setting it in a scope must be a
mistake.
2015-08-13 13:41:03 -07:00
Aaron Patterson
ec895189e4 pull formatted up the stack
this reduces the number of times we have to mutate the options hash.
2015-08-12 16:54:35 -07:00
Aaron Patterson
d61e3c79dc add a regression test for scoped format params
This just ensures that `format` is applied to things inside the scope
2015-08-12 16:54:35 -07:00
Aaron Patterson
e2735b2b32 add a regression test for adding arbitrary keys to scope 2015-08-12 15:17:21 -07:00
Aaron Patterson
1c94317539 add a method to Scope for getting mapping options
Eventually we don't want to expose the "options" hash from scope, only
read values from it.  Lets start by adding a reader method.
2015-08-12 14:30:54 -07:00
Aaron Patterson
b46c67fb47 pull via all the way out of add_route 2015-08-12 14:30:53 -07:00
Aaron Patterson
4c641c6e36 add a test for adding "via" using scope 2015-08-12 14:30:53 -07:00
Aaron Patterson
b59ff24207 pull via extraction up
We're going to try pulling this up further, and check `via` validity
sooner.  This way we don't have to do a bunch of processing on `options`
hashes only to find out that the route is incorrect
2015-08-12 14:30:53 -07:00
Sean Griffin
e69364bc2d Merge pull request #21203 from denniss/issue-21199
Authorization scheme should be case insensitive. Fixes #21199
2015-08-11 17:25:00 -06:00
Aaron Patterson
97d7dc48d6 pull to up
this way we don't have to insert / delete it from the options hash so
many times.
2015-08-11 16:16:09 -07:00
Dennis Suratna
dec2f52fa4 Authorization scheme should be case insensitive. Fixes #21199 2015-08-11 15:59:44 -07:00
Aaron Patterson
5935e4c882 push option decomposition up a bit more
I think we can find the original place where `action` is added to the
options hash now.
2015-08-11 14:49:19 -07:00
Aaron Patterson
97bbde7600 pull up the "options.delete(:controller)" logic
we want to try to pull this logic up to where the user actually passed
in "controller" so that it's close to the related call.  That way when
we're down the stack, we don't need to wonder "why are we doing this?"
2015-08-11 14:49:18 -07:00
eileencodes
286cb890de Refactor route assertion methods in resources test
The tests and methods were hard to read with `options[:options]` all
over the place. This refactoring makes the code easier to understand.

The change came out of work for moving the underlying code of controller
tests to integraiton tests.
2015-08-08 11:53:05 -04:00
Rafael Mendonça França
d919fd88ec Merge pull request #11352 from xaviershay/dispatcher-api
Allow a custom dispatcher to be provided to routing.
2015-08-08 12:22:21 -03:00
eileencodes
12f08acbac Fix deprecation warning in tests
Using the string version of the class reference is now deprecated when
referencing middleware. This should be written as a class not as a string.

Deprecation warning that this change fixes:
```
DEPRECATION WARNING: Passing strings or symbols to the middleware
builder is deprecated, please change
them to actual class references.  For example:
  "ActionDispatch::ShowExceptions" => ActionDispatch::ShowExceptions
```
2015-08-08 10:38:09 -04:00
eileencodes
c8b8295583 Refactor to remove DrawOnce module
We were doing extra work that could be pushed off to Integration test
and SharedRoutes. Creating an extra module isn't necessary when those
are created by their respective classes.
2015-08-08 10:15:35 -04:00
Xavier Shay
2992b1c04c Allow a custom dispatcher to be provided to routing. 2015-08-07 20:06:24 -07:00
Aaron Patterson
1f80f3a373 remove vestigial code
Looks like this was left over from converting Rails to Rack.  I think
it's safe to remove now.
2015-08-07 16:17:22 -07:00
Aaron Patterson
2a3c47ff5d finish deprecating handling strings and symbols
since we only work with instances of classes, it greatly simplifies the
`Middleware` implementation.
2015-08-07 15:37:31 -07:00
Aaron Patterson
83b767cef9 Using strings or symbols for middleware class names is deprecated.
Convert things like this:

  middleware.use "Foo::Bar"

to this:

  middleware.use Foo::Bar
2015-08-07 15:37:31 -07:00
Aaron Patterson
27eddbb332 simplify the Middleware constructor
We should do the hard work outside the constructor.  Also fix the tests
to not directly construct middleware objects, but to go through the
stack object.
2015-08-07 15:37:31 -07:00
Michael Grosser
a278630f5f do not add common ports to HTTP_HOST
- webservers do not do it
 - it makes redirect urls ugly when request.host is used for redirection
2015-08-06 17:33:32 -07:00
Aaron Patterson
6d85804bc6 ExceptionWrapper doesn't need to know about env
ExceptionWrapper only cares about the backtrace cleaner, so lets just
pass the cleaner to the wrapper.  It does not need to know that env
exists or what key the backtrace cleaner is stored in
2015-08-06 15:59:44 -07:00
Aaron Patterson
8f27d6036a use a request object to reduce string allocations and not know about ENV keys 2015-08-06 15:12:19 -07:00
Rafael Mendonça França
19d46e849e Merge pull request #21131 from eagletmt/percent-filename
Fix Encoding::UndefinedConversionError with multibyte UTF-8 filename containing "%" character
2015-08-06 17:20:59 -03:00
Matthew Gerrior
3004cc8177 Adds missing argument handling for ActionController::TestSession to
allow testing controllers that use session#fetch with a default value.
2015-08-06 15:29:45 -04:00
Kohei Suzuki
b5ae1be2cd Add failing spec on utf8 filename with percent character 2015-08-04 21:27:22 +09:00
Aditya Kapoor
7481039225 Add missing assertion for test_route_with_colon_first 2015-08-03 13:48:15 +05:30
amitkumarsuroliya
eb55bd3430 Remove duplicity in tests 2015-08-03 12:31:19 +05:30
Aditya Kapoor
854ab2e1e6 add missing tests for action regexp 2015-08-02 13:39:40 +05:30
Rafael Mendonça França
32b0db266c Merge pull request #20590 from vngrs/set_default_charset
Document, refactor and create test case for ActionDispatch::Response
2015-07-27 17:31:24 -03:00
Roque Pinel
12b0b26df7 Fix state being carried over from previous transaction
This clears the transaction record state when the transaction finishes
with a `:committed` status.

Considering the following example where `name` is a required attribute.
Before we had `new_record?` returning `true` for a persisted record:

```ruby
  author = Author.create! name: 'foo'
  author.name = nil
  author.save        # => false
  author.new_record? # => true
```
2015-07-20 09:12:01 -06:00
Roque Pinel
780af27bf9 Fix exception overwritten for parameters fetch method
When executing an `ActionController::Parameters#fetch` with a block
that raises a `KeyError` the raised `KeyError` will be rescued and
converted to an `ActionController::ParameterMissing` exception,
covering up the original exception.

[Jonas Schubert Erlandsson & Roque Pinel]
2015-07-18 18:48:41 -04:00
Prem Sichanugrist
8cb8ce98d9 Stop using deprecated render :text in test
This will silence deprecation warnings.

Most of the test can be changed from `render :text` to render `:plain`
or `render :body` right away. However, there are some tests that needed
to be fixed by hand as they actually assert the default Content-Type
returned from `render :body`.
2015-07-17 22:27:33 -04:00
Prem Sichanugrist
6790228b39 Add deprecation warning for render :text
We've started on discouraging the usage of `render :text` in #12374.
This is a follow-up commit to make sure that we print out the
deprecation warning.
2015-07-17 21:12:47 -04:00
Robin Dupret
ae1b96cfcd Skip a few failing tests on JRuby with the attached tickets 2015-07-17 15:00:00 +02:00
Prem Sichanugrist
14a3bd520d Make AC::Parameters not inherited from Hash
This is another take at #14384 as we decided to wait until `master` is
targeting Rails 5.0. This commit is implementation-complete, as it
guarantees that all the public methods on the hash-inherited Parameters
are still working (based on test case). We can decide to follow-up later
if we want to remove some methods out from Parameters.
2015-07-15 11:11:36 -04:00
Aaron Patterson
468a55b741 Merge pull request #20866 from jdantonio/countdown-latch
Replace `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch` from concurrent-ruby.
2015-07-14 11:06:20 -07:00
Rafael Mendonça França
7645a5f85d Merge pull request #20877 from sikachu/rename-ac-test_response
Change AC::TestResponse to AD::TestResponse
2015-07-14 12:26:30 -03:00
Aaron Patterson
9cff248469 only call methods that are on the superclass
We want to treat the response object as if it's a real response object
(not a test object), so we should only call methods that are on the
superclass.
2015-07-14 07:46:17 -07:00
Prem Sichanugrist
e26d11c876 Change AC::TestResponse to AD::TestResponse
ActionController::TestResponse was removed in d9fe10c and caused a test
failure on Action View as its test case still refers to it.
2015-07-14 09:27:42 -04:00
Aaron Patterson
908bc79729 use a lookup table for assert_response
We shouldn't depend on specific methods imlemented in the TestResponse
subclass because the response could actually be a real response object.

In the future, we should either push the aliased predicate methods in
TestResponse up to the real response object, or remove them
2015-07-13 18:10:36 -07:00
Aaron Patterson
d9fe10cb8a only have one TestResponse class 2015-07-13 17:52:02 -07:00
Jerry D'Antonio
284a9ba8ec Replaced ActiveSupport::Concurrency::Latch with concurrent-ruby.
The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
2015-07-13 15:44:21 -04:00
Aaron Patterson
140d5a3b2f use Rack::Test::UploadedFile when uploading files
We should use rack-test's upload file objects on the test side so that
we will be able to correctly generate mime blob posts in the future
2015-07-09 11:51:45 -07:00
Aaron Patterson
394b7be036 set parameters as a query string
We should convert request parameters to a query string, then let the
request object parse that query string.  This should give us results
that are more similar to the real-world
2015-07-09 10:12:19 -07:00
Aaron Patterson
40ed4eefe4 use JSON to communicate between the controller and the tests 2015-07-09 07:50:41 -07:00
Aaron Patterson
5ea8efecd0 build and assign parameters rather than rely on mutations
We should assign parameters to the request object rather than mutate the
hash that is returned by `query_parameters` or `request_parameters`
2015-07-08 16:43:58 -07:00
Aaron Patterson
f65fd25f04 request objects are no longer recycled
Instead of trying to manually clear out a request object, lets just
allocate a new one.  The rack ENV is reused and cleaned (still), but the
request object is not.
2015-07-08 16:23:32 -07:00
Aaron Patterson
b5a9525932 pass the variant as a parameter to more reflect real world apps 2015-07-08 16:15:50 -07:00
Aaron Patterson
78a5124bf0 add a new constructor for allocating test requests 2015-07-08 16:09:49 -07:00
Aaron Patterson
db41f33d7c make env a required parameter 2015-07-08 15:59:30 -07:00
Aaron Patterson
4b1a0adf54 remove call to build_request 2015-07-08 15:14:41 -07:00
Aaron Patterson
460079a771 let the superclass build the request and response
We should leverage the request / response objects that the superclass
has already allocated for us.
2015-07-08 14:15:53 -07:00
Aaron Patterson
59a9068c3f pass variants in rather than mutating the request.
Variants are typically set in the controller based on some attribute of
the request that the browser sent.  We should make our tests more in
line with reality by doing the same and not mutating the request object.
2015-07-07 15:51:01 -07:00
eileencodes
8363b879fe pass cookies from the jar in the HTTP_COOKIE header
we should be pushing the cookies in via headers rather than maintaining
some object and "recycling" it.
2015-07-07 14:31:34 -07:00
Arthur Nogueira Neves
e598967548 Merge pull request #13897 from gmalette/nested-parameter-filtering-2
Allow filtering params based on parent keys
2015-07-06 16:33:01 +02:00
Kasper Timm Hansen
90ebba6836 Fix the random caching test failure. 2015-07-05 13:53:20 +02:00
eileencodes
4d7b507073 Improve error messages in cookies_test
Using `assert_predicate` and `assert_match` instead of just `assert` is
preferrable because better error messages are output.

In the case of `assert response.cookies.empty?` the error message was
`Failed assertion, no message given.` but now with `assert_predicate` it
will be `Expected {"user_name"=>"david"} to be empty?.`

For `assert_match(/user_name=david/,
response.headers["Set-Cookie"])` as well, the message returned was
unhelpful - `Failed assertion, no message given.` but now will tell what
was expected and what was returned with `Expected /user_name=david/ to
match "user_name=nope; path=/".`
2015-06-27 16:48:20 -04:00
Kasper Timm Hansen
991e98f564 Merge pull request #20276 from davetron5000/revert-head-on-no-template
Allow default_render to take a block to customize behavior when there's no template
2015-06-27 22:18:17 +02:00
Rafael Mendonça França
75b63de5ed Merge pull request #19431 from hmarr/head-routing
Respect routing precedence for HEAD requests
2015-06-22 19:34:37 -03:00
Guillaume Malette
33b93174f0 Allow filtering params based on parent keys
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 %>' } }
2015-06-22 10:04:11 -04:00
Dave Copeland
6fda6c3778 Override default_render's behavior with a block
In 0de4a23 the behavior when there is a missing template was changed to
not raise an error, but instead head :no_content.  This is a breaking
change and some gems rely on this happening.

To allow gems and other code to work around this, allow
`default_render` to take a block which, if provided, will
execute the contents of that block instead of doing the `head :no_content`.
2015-06-20 12:00:07 -04:00
Arthur Neves
ffba8f79a2
Revert "Merge pull request #20584 from arthurnn/fix_url"
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.

As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
2015-06-17 20:17:44 +02:00
Mehmet Emin İNAÇ
422292dc98 Document, refactor and create test case for ActionDispatch::Response#charset= method 2015-06-17 00:58:50 +03:00
Arthur Neves
e23b314945
Catch InvalidURIError on bad paths on redirect.
Handle URI::InvalidURIError errors on the redirect route method, so it
wont raise a 500 if a bad path is given.
2015-06-16 23:27:49 +02:00
Aaron Patterson
50176b59fa remove header= on the response object.
People should be free to mutate the header object, but not to set a new
header object.  That header object may be specific to the webserver, and
we need to hide it's internals.
2015-06-15 17:54:08 -07:00
Mehmet Emin İNAÇ
cf81a3bae0 Deprecate passing hash as first parameter into ActionController::Head 2015-06-15 23:53:45 +03:00
Kasper Timm Hansen
374b163999 Fix flakyness.
Brought on by my own stupidity :)
2015-06-15 22:04:43 +02:00
Fumiaki MATSUSHIMA
bb0186cf55 ActionDispatch::SSL should keep original header's behavior
`ActionDispatch::SSL` changes headers to `Hash`.
So some headers will be broken if there are some middlewares
on ActionDispatch::SSL and if it uses `Rack::Utils::HeaderHash`.
2015-06-14 23:20:04 +09:00
Yuki Nishijima
5226058163 Add the ability of returning arbitrary headers to ActionDispatch::Static
Now ActionDispatch::Static can accept HTTP headers so that developers
will have control of returning arbitrary headers like
'Access-Control-Allow-Origin' when a response is delivered. They can
be configured through `#config.public_file_server.headers`:

  config.public_file_server.headers = {
    "Cache-Control"               => "public, max-age=60",
    "Access-Control-Allow-Origin" => "http://rubyonrails.org"
  }

Also deprecate `config.static_cache_control` in favor of
`config.public_file_server.headers`.
2015-06-13 09:30:23 -07:00
Jorge Bejar
6c16577311 Return 204 if render is not called in API controllers 2015-06-11 16:54:17 -03:00
Jorge Bejar
8d3e6e5f4d Add test coverage for implicit render in empty actions 2015-06-11 16:54:16 -03:00
Jorge Bejar
a2c9a73084 Include ParamsWrapper in AC::API
ParamsWrapper was initially removed from API controllers according to
the following discusision:
https://github.com/rails-api/rails-api/issues/33

However, we're including it again so Rails API devs can decide
whether to enable or disable it.
2015-06-11 16:54:16 -03:00
Jorge Bejar
08cfe34174 Rename test methods in api conditional get controller tests 2015-06-11 16:54:14 -03:00
Jorge Bejar
674dab30bc Routes resources avoid :new and :edit endpoints if api_only is enabled 2015-06-11 16:54:14 -03:00
Santiago Pastorino
099055de66 Remove extra whitespaces 2015-06-11 16:54:13 -03:00
Santiago Pastorino
440b334cbb Use new hash syntax 2015-06-11 16:54:13 -03:00
Santiago Pastorino
e7b89f1081 Remove Unneeded ApiPublicExceptions middleware, PublicExceptions already does the work 2015-06-11 16:54:13 -03:00
Santiago Pastorino
4c1b437ed7 Use nex hash syntax on tests 2015-06-11 16:54:13 -03:00
Santiago Pastorino
3adb5eac3b Add ApiPublicException middleware 2015-06-11 16:54:10 -03:00
Santiago Pastorino
2d86b6d9ae Move Model test class inside RenderersApiController namespace 2015-06-11 16:54:09 -03:00
Santiago Pastorino
032778eefb Add ActionController API functionality 2015-06-11 16:54:09 -03:00
Yuki Nishijima
a888c3cdc9 Change the index arg of ActionDispatch::Static#new to a kwarg 2015-06-11 04:34:11 -07:00
Aaron Patterson
8037d7eacd extract required_defaults from the conditions hash before constructing the route
this way we can remove the strange "respond_to?" conditional in the
`matches?` loop
2015-06-08 17:18:32 -07:00
Rafael Mendonça França
cf484e3ee3 Merge pull request #19094 from phoet/have_bearer_be_valid_as_well
Have Bearer be valid as well
2015-06-01 12:41:18 -03:00
Rafael Mendonça França
bdfc662a11 Merge pull request #20138 from tgxworld/deprecated_assert_template
Deprecate `assert_template` and `assigns()`.
2015-06-01 12:39:03 -03:00
Rafael Mendonça França
bd83caa666 Merge pull request #20284 from kaspth/fix-caching-test
Move expectation to instance level.
2015-06-01 12:38:08 -03:00
phoet
4b4e890781 allow Bearer as well as Token 2015-06-01 11:41:26 +02:00
phoet
90918b5f22 actually test what the name says 2015-06-01 11:41:26 +02:00
Kasper Timm Hansen
4abe29d813 Replace expectation with state check.
The tests would still pass if the cache call in the rendered templates were removed.
2015-05-30 18:57:10 +02:00
Guo Xiang Tan
ca83436d1b Remove assigns and assert_template. 2015-05-30 14:13:57 +08:00
Arun Agrawal
fbe41a2477 Fix warning about ambiguous first argument 2015-05-29 07:38:45 +02:00
Rafael Mendonça França
73aab036ee Merge pull request #20017 from eliotsykes/configurable-static-index-filename
config.static_index configures directory Index "index.html" filename
2015-05-28 18:53:00 -03:00
Mehmet Emin İNAÇ
44781b6e97 Deprecate :nothing option for render method
`head` method works similar to `render` method with `:nothing` option
2015-05-28 15:13:32 +03:00
Eliot Sykes
3ff39494cd config.static_index configures directory index "index.html" filename
Set `config.static_index` to serve a static directory index file not
named `index`. For example, to serve `main.html` instead of `index.html`
for directory requests, set `config.static_index` to `"main"`.
2015-05-28 09:41:00 +01:00
Rafael Mendonça França
f02f287242 Merge pull request #19808 from byroot/action-parameter
[PoC] Stop shadowing parameters named `action`
2015-05-27 21:43:45 -03:00
Mehmet Emin İNAÇ
01d4e060e2 Add assertion for get? method into test cases 2015-05-27 15:54:56 +03:00
Arthur Nogueira Neves
c36423984d Merge pull request #17788 from sivagollapalli/master
Issue#17703 Test case for tempfile attribute
2015-05-20 22:41:19 +02:00
Rafael Mendonça França
d4cfd54308 Prefer assert_not over refute 2015-05-18 19:33:25 -03:00
Valentine Valyaeff
bad30ed46c ActionDispatch::Journey::Routes#empty? test cases 2015-05-19 01:21:20 +03:00
Prem Sichanugrist
7cb9e20c6c Silence ambiguous first argument warning
This silences:

    actionpack/test/journey/route_test.rb:33: warning: ambiguous first
    argument; put parentheses or a space even after `/' operator
2015-05-04 10:15:50 -04:00
Keenan Brock
ba924a514b Give authentication methods the ability to customize response message.
Digest allowed the messages.
Add the same feature to basic and token
2015-05-03 22:21:19 -04:00
Arthur Nogueira Neves
86929c00c0 Merge pull request #18392 from brainopia/fix_route_requirements
Correct route requirements by overriding defaultls
2015-04-27 09:15:22 -04:00
Rafael Mendonça França
505fa60be2 Merge pull request #19904 from zzak/rm_route_wrapper_internal_hacks
Rm route wrapper internal hacks
2015-04-26 17:27:17 -03:00
Prathamesh Sonpatki
0ad06f2545 Removed unused code from request_forgery_protection tests 2015-04-26 18:52:37 +05:30
Jorge Bejar
8c180cdaf6 Fix rake routes for api apps
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2015-04-25 23:14:28 -07:00
Akira Matsuda
9b3fa766d4 Why do we add a top-level constant here? 2015-04-25 17:07:54 +09:00
Bryce Boe
0eaae0291b Remove unused WorkshopsController class in redirect_test. 2015-04-23 16:12:01 -04:00
Jean Boussier
fc9cd89de9 Allow to parameters named action or controller from AC::TestCase helpers 2015-04-18 16:08:33 -04:00
Brian Weaver
c4a83b5454 Fix broken IPv6 addresses handling 2015-04-16 20:57:31 -04:00
Siva Gollapalli
76d8a2a638 Issue#17703 Test case for tempfile attribute
+ To avoid regression I am adding this test case on action pack

Changed to assert from assert_equal

+ Added msg to assertion

Modified msg
2015-04-16 23:11:23 +05:30
Rafael Mendonça França
9ec54d9500 Merge pull request #19736 from kmcphillips/master
Set default form builder for a controller
2015-04-14 11:23:49 -04:00
eileencodes
db8897c2de Use silence_warnings on StaticTests
When 7e504927 was merged setting `Encoding.default_internal` and
`Encoding.default_external` would throw a warning when the ActionPack
tests were run.

Example warning: `actionpack/test/dispatch/static_test.rb:12: warning:
setting Encoding.default_external`

This patch silences the warnings as other similar tests do for setting
default_internal and default_external.
2015-04-14 08:54:13 -04:00
Kevin McPhillips
2b8acdcd21 Override default form builder for a controller 2015-04-13 23:43:34 -04:00
Santiago Pastorino
e085a7ddb8 Revert "Merge pull request #19682 from supercaracal/fix_force_ssl_redirection_flash_error"
This reverts commit d215620340be7cb29e2aa87aab22da5ec9e6e6a7, reversing
changes made to bbbbfe1ac02162ecb5e9a7b560134a3221f129f3.
2015-04-12 22:26:35 -03:00
Taishi Kasuga
3449da4a6c fix a wrong feature test method name 2015-04-11 18:59:56 +09:00
Toshi MARUYAMA
7e50492709 [Rails4 regression] prevent thin and puma cause error in Non ASCII URL on Windows
* https://github.com/rails/rails/issues/19187
* https://github.com/rails/rails/pull/19533
* https://github.com/macournoyer/thin/issues/268

These are serious Rails 4 regression for Redmine Bitnami Windows users.

https://community.bitnami.com/t/problems-with-3-0-1-installation-see-report-inside/30195/

It is not caused on webrick users.

Related:

* https://github.com/rack/rack/issues/732#issuecomment-67677272
* https://github.com/phusion/passenger/issues/1328
2015-04-09 19:25:12 -03:00
Toshi MARUYAMA
2a73b5999e wrap "require 'drb/unix'" by bgin-end at test/abstract_unit.rb
Related: #19617, #19187, #19533, #19689, #19675.

'drb/unix' does not exist on mingw.
2015-04-09 19:25:11 -03:00
Taishi Kasuga
242c5c7ae4 fix fails to force_ssl_redirection if session_store is disabled 2015-04-09 11:21:00 +09:00
Rafael Mendonça França
041c2c879a Merge pull request #19633 from y00rb/sort_router_parameters_duplicated_keys
avoid error when sort mixture keys in symbol and string
2015-04-08 19:01:11 -03:00
Yang Bo
a77de09812 sort_by instead of sort
it is avoid sort errot within different and mixed keys.
used `sort_by` + `block` to list parameter by keys.
keep minimum changes
2015-04-08 22:18:56 +08:00
eileencodes
188934cdac Fix ActionPack tests after changes to missing template logger
After merging #19377 ActionPack tests were missing a require for
`ActiveSupport::LogSubscriber::TestHelper` and change didn't take
into account that logger could be nil. Added the require and only log to
info if logger exists.

This wasn't caught earlier because these tests only run after a merge.
2015-04-06 09:03:13 -04:00
Stephen Bussey
0de4a23d1c head no_content when there is no template or action performed 2015-04-05 15:46:50 -04:00
Sergey Alekseev
7f546318d5 write a test for #form_data?
The initial attempt was to remove the method at all in
4926aa68c9.

The method overrides Rack's `#form_data?`
6f8808d420/lib/rack/request.rb (L172-L184).
Which may have some incorrect implementation actually. `type.nil?` isn't possible I suppose. I'll check.
2015-03-31 10:06:22 +03:00
Xavier Noria
8798788c65 Merge pull request #19544 from shuhei/fix-parameters-const-missing
Return super in ActionController::Parameters.const_missing
2015-03-28 10:01:25 +01:00
Shuhei Kagawa
1b0526eaac Return super in ActionController::Parameters.const_missing
The current implementation of ActionController::Parameters.const_missing
returns `ActionController::Parameters.always_permitted_parameters` even
if its `super` returns a constant without raising error. This prevents its
subclass in a autoloading module/class from taking advantage of
autoloading constants.

    class SomeParameters < ActionController::Parameters
      def do_something
        DefinedSomewhere.do_something
      end
    end

In the code above, `DefinedSomewhere` is to be autoloaded with
`Module.const_missing` but `ActionController::Parameters.const_missing`
returns `always_permitted_parameters` instead of the autoloaded
constant.

This pull request fixes the issue respecting `const_missing`'s `super`.
2015-03-28 10:40:58 +09:00
Rafael Mendonça França
9c3c07b325 Define a setup method instead of using setup as block
setup as block run before setup actlually runs so it will fail for our
case
2015-03-27 16:29:15 -03:00
George Claghorn
9d9cc4777b Provide friendlier access to request variants
Closes #18933.
2015-03-24 12:49:27 -05:00
Andrew White
550c1f0950 Fix failing tests for #19474 2015-03-23 13:15:59 +00:00
Gaurav Sharma
29efc6ee05 remove old unavailable link with relevant fix 2015-03-23 11:18:14 +05:30
adam
b49cac80de Fix handling of empty X_FORWARDED_HOST header.
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.
2015-03-20 20:32:30 +00:00
Harry Marr
34a52c6bce Respect routing precedence for HEAD requests
Fixes the issue described in #18764 - prevents Rack middleware from
swallowing up HEAD requests that should have been matched by a
higher-precedence `get` route, but still allows Rack middleware to
respond to HEAD requests.
2015-03-20 18:13:59 +00:00
Jeremy Kemper
5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
2015-03-20 08:14:11 -07:00
eileencodes
adae55f476 Fix kwargs warning in test_get_xml
ActionDispatch::IntegrationTest HTTP request methods will accept only
certain kwargs in the future. This test caused a deprecation warning
when running ActionPack tests. Added `params` and `headers` to fix.
2015-03-20 08:48:10 -04:00
Akshay Vishnoi
c27b2df561 Fix test messages use directly true, false and nil instead of their symbol 2015-03-19 23:47:58 +05:30
Damien Mathieu
d578cbfb5c don't fallback to RACK_ENV when RAILS_ENV is not present 2015-03-19 10:06:28 +01:00
Boris Peterbarg
4be3997c9f Compare content_type with Mime::XML instead of regexp
Regexp is broken for both content types including charsets and for
integration tests, where the content_type is a Mime::Type and not String
2015-03-16 06:35:00 +02:00
Rafael Mendonça França
cf5ec92a8b Merge pull request #19291 from hired/return-truthy-value-from-head
Return truthy value from head method
2015-03-13 11:06:20 -03:00
Joel Hayhurst
d5efb1f9bd Return true from head method
It was returning false in normal circumstances.
This broke the `head :ok and return if` construct.
Add appropriate test.
2015-03-12 14:39:22 -07:00
Guillermo Iguaran
ccf8678cec Merge pull request #19309 from f1sherman/dont-set-session-options-id
Use request.session.id instead of request.session_options[:id]
2015-03-12 11:30:12 -05:00
Brian John
82402e6583 Use request.session.id instead of request.session_options[:id]
As of the upgrade to Rack 1.5, request.session_options[:id] is no
longer populated. Reflect this change in the tests by using
request.session.id instead.

Related change in Rack:
https://github.com/rack/rack/commit/83a270d6
2015-03-12 09:52:38 -05:00
Kohei Suzuki
b60c1fe97b Also skip Content-Encoding and Vary header if 304 2015-03-12 23:32:07 +09:00
Kohei Suzuki
d4103fc232 304 response should not include Content-Type header
Rack::Lint raises an error saying "Content-Type header found in 304
response, not allowed".
2015-03-10 23:39:08 +09:00
eileencodes
2e4a01b92c Call super last in before_setup
This fixes the reasons 4cf3b8a, 303567e, and fa63448 needed to be
reverted in 7142059. The revert has been reverted and this fixes
the issues caused previously.

If we call `super` first we will end up nuking the session settings in the
application tests that do `setup do` - so any session login or cookie
settings will not be persisted thoughout the test sessions.

Calling `super` last prevents `@integration_session` from getting nuked
and set to nil if it's already set.

Test added to prevent regression of this behavior in the future.
2015-03-09 17:11:15 -04:00
eileencodes
d5e55e960c Revert "Revert integration test refactoring that caused app test regressions"
This reverts commit 714205988315d2f98aa3e749747c44470e18676b.
2015-03-09 17:10:24 -04:00
Aaron Patterson
798a14a638 pass a config to the route set
This way we can get the relative_url_root from the application without
setting another global value
2015-03-05 13:12:06 -08:00
Guo Xiang Tan
dad40bf9ea Run ActionPack test cases in random order. 2015-03-06 00:24:22 +08:00
Aaron Patterson
c2108926a4 Drop request class from RouteSet constructor.
If you would like to use a custom request class, please subclass and implemet
the `request_class` method.
2015-03-04 11:02:24 -08:00
Rafael Mendonça França
44ff0313c1 Merge pull request #18775 from yasyf/issue_5122
Fallback to RAILS_RELATIVE_URL_ROOT in `url_for`
2015-03-03 17:19:42 -03:00
Eileen M. Uchitelle
f32b6e243a Merge pull request #19147 from gsamokovarov/work-around-ruby-10695
Work around for upstream Ruby bug #10685
2015-03-02 18:22:31 -05:00
Aaron Patterson
12f2fc56aa Merge pull request #15806 from tgxworld/partition_routes_during_setup
Partition routes during setup.
2015-03-02 15:02:14 -08:00
Zoltan Kiss
f5b192837a Remove unneeded comment. [ci skip] 2015-03-02 11:03:33 -06:00
Robin Dupret
562b0b2368 Skip the failing tests on Rubinius for now 2015-03-02 17:28:12 +01:00
Robin Dupret
586fe4471d Avoid accurate assertions on error messages
Since there are disparities between the raised error messages on the
different implementations, let's avoid being too accurate.
2015-03-02 14:05:07 +01:00
Robin Dupret
022c8be2cf Avoid parallelizing Action Pack's tests on Rubinius
Since the `ForkingExecutor` class seems to be pretty slow on Rubinius
due to DRb (c.f. http://git.io/xIVg), let's avoid running tests with
it on this platform.

Also, the `parallelize_me!` call make the suite to output a bunch of
errors due to rubinius/rubinius#2934 since there are thread-safety
problems with autoloading.
2015-03-02 14:05:07 +01:00
Genadi Samokovarov
707a433870 Work around for upstream Ruby bug #10685
In f6e293ec54f02f83cdb37502bea117f66f87bcae we avoided a segfault in the
tests, however I think we should try to avoid the crash, as it may
happen in user code as well.

Here is what I distiled the bug down to:

```ruby
# Rails case - works on 2.0, 2.1; crashes on 2.2
require 'action_dispatch'

ActionDispatch::Response.new(200, "Content-Type" => "text/xml")

# General case - works on 2.0, 2.1; crashes on 2.2
def foo(optional = {}, default_argument: nil)
end

foo('quux' => 'bar')
```
2015-03-01 16:31:20 +02:00
eileencodes
22e0a22d5f Fix segmentation fault in ActionPack tests
Introduced in f6e293e ActionPack tests began sefaulting. I found that it
was the kwargs and the test causing the seg fault was missing the new
default_headers argument.
2015-02-28 22:34:47 -05:00
Carlos Antonio da Silva
242632167c Merge pull request #19104 from y-yagi/fix_skip_filter
fix NameError in `skip_filter`. callback doesn't exist.
2015-02-27 07:27:42 -03:00
Jeremy Kemper
7142059883 Revert integration test refactoring that caused app test regressions
Haven't diagnosed yet. No similarly failing tests in Rails to work from.

cc @tenderlove, @eileencodes

Revert "there is always an integration session, so remove the check"
Revert "lazily create the integration session"
Revert "use before_setup to set up test instance variables"

This reverts commits 4cf3b8ac47f109fa83a6f66eb97d6cb0eace0d05, 303567e554de26822f3107be55c471d6477a745f, and fa63448420d3385dbd043aca22dba973b45b8bb2.
2015-02-26 18:03:40 -07:00
Jeremy Kemper
a13e52b422 Revert "Merge pull request #18764 from tsun1215/master"
This reverts commit b6dd0c4ddebf5e7aab0a669915cb349ec65e5b88, reversing
changes made to de9a3748c436f849dd1877851115cd94663c2725.
2015-02-26 17:04:08 -07:00
yuuji.yaginuma
0eec7d2c96 fix NameError in skip_filter. callback doesn't exist. 2015-02-27 09:03:31 +09:00
Richard Schneeman
f069b41321 Merge pull request #18434 from brainopia/change_filter_on_rails_info_routes
Change filter on /rails/info/routes to use an actual path regexp from rails
2015-02-26 12:59:43 -06:00