Commit Graph

5671 Commits

Author SHA1 Message Date
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
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