Commit Graph

9835 Commits

Author SHA1 Message Date
Robin Dupret
8a74190121 Tiny documentation edits [ci skip] 2015-03-03 21:30:20 +01: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
Zachary Scott
3d69222ca9 Merge pull request #19181 from davydovanton/update-helper-docs
[ci skip] Add documentation for Helpers#all_helpers_from_path
2015-03-02 14:51:58 -08:00
Anton Davydov
7fd2de464e [ci skip] Add documentation for Helpers#all_helpers_from_path 2015-03-03 01:14:48 +03:00
Aaron Patterson
0814bb62e5 be optimistic about missing route keys
this patch makes errors slightly more expensive when someone is missing
a route key, but in exchange it drops 4 allocations per `url_for` call.
Since missing a route key is an error, optimizing for the non-error path
seems like a good trade off
2015-03-02 11:26:23 -08:00
Aaron Patterson
b1051c5dfa use arg size for parallel iteration
we already know the length of the args, so we can use that length for
parallel iteration and cut down on allocations for `url_for` calls.
2015-03-02 11:16:09 -08:00
Aaron Patterson
37654d12ae ask the routes objects for its Rack env key
this centralizes the logic for determining the script name key and drops
object allocations when calling `engine_script_name` (which is called on
each `url_for`).
2015-03-02 11:01:07 -08:00
Aaron Patterson
4cfa10cda5 refactor handle_model to use private helper methods for generation 2015-03-01 16:16:15 -08:00
Aaron Patterson
95c76a7cf3 drop allocations for string and class polymorphic routes 2015-03-01 16:16:15 -08:00
Aaron Patterson
402331ed2d drop string allocations per model url_for call in views
```ruby
article = Article.new.tap(&:save!)
view.url_for article

result = ObjectSpace::AllocationTracer.trace do
  3000.times { view.url_for article }
end
p ObjectSpace::AllocationTracer.allocated_count_table[:T_STRING] / 3000
```
2015-03-01 16:05:58 -08:00
Aaron Patterson
cad20f720c move _generate_paths_by_default to where it is used
_generate_paths_by_default wasn't used in AD::Routing::UrlFor, so we
should be able to move it where it is used in AV::Routing
2015-03-01 13:35:24 -08: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
Vijay Dev
dcfd4bf223 Merge branch 'master' of github.com:rails/docrails 2015-03-01 12:45:56 +00:00
Aaron Patterson
92849df732 drop allocations when handling model url generation 2015-02-28 16:00:27 -08:00
Vipul A M
cdaab2c479 Removed non-standard and unused require 'active_support/deprecation' from parts out of active_support. 2015-02-27 23:20:09 +05:30
Iain Beeston
a5eddb534f Explained how to set session expiry through session_store config
Most session stores offer an :expire_after option, but it's largely
undocumented. Cookie store also supports a number of options via
rack (these used to be documented in rails 2.3)
2015-02-27 10:29:44 +00: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
Guo Xiang Tan
89edfbd3a4 Partition routes during setup.
Partitioning of all the routes is currently being done during the
first request. Since there is no need to clear the cache for
`partitioned_routes` when adding a new route. We can move the
partitioning of the routes during setup time.
2015-02-26 12:18:20 +08:00
Jeremy Kemper
f6e293ec54 Fix default headers in test responses
Fixes regression in #18423. Merge default headers for new responses,
but don't merge when creating a response from the last session request.

hat tip @senny ❤️
2015-02-25 09:49:25 -07:00
Yasyf Mohamedali
6c14252d2c Fallback to RAILS_RELATIVE_URL_ROOT in url_for.
Fixed an issue where the `RAILS_RELATIVE_URL_ROOT` environment
variable is not prepended to the path when `url_for` is called.
If `SCRIPT_NAME` (used by Rack) is set, it takes precedence.
2015-02-24 16:04:27 -05:00
Rafael Mendonça França
6976e1da07 Merge pull request #19060 from iainbeeston/deprecate-skip-action-callback
Deprecate `AbstractController::Callbacks#skip_action_callback`
2015-02-24 13:33:16 -03:00
Iain Beeston
3fbc632843 Deprecate AbstractController::Callbacks#skip_action_callback
As part of #19029, in future `skip_before_action`, `skip_after_action` and
`skip_around_action` will raise an ArgumentError if the specified
callback does not exist. `skip_action_callback` calls all three of these
methods and will almost certainly result in an ArgumentError. If anyone
wants to remove all three callbacks then they can still call the three
individual methods. Therefore let's deprecate `skip_action_callback` now
and remove it when #19029 is merged.
2015-02-24 08:17:24 +00:00
brainopia
321db4aa2e Change filter on /rails/info/routes to use an actual path regexp from rails
Change filter on /rails/info/routes to use an actual path regexp from rails
and not approximate javascript version. Oniguruma supports much more
extensive list of features than javascript regexp engine.

Fixes #18402.
2015-02-23 19:57:01 +03:00
yuuji.yaginuma
ea85b39536 fix method name in mime type example. Mime::Type.[] doesn't exist. [ci skip] 2015-02-23 22:38:33 +09:00
Rafael Mendonça França
027d484f1d Prefer request_id over uuid and test the alias 2015-02-20 20:47:59 -02:00
David Ilizarov
7f5cf3a3da Aliased the ActionDispatch::Request#uuid method with ActionDispatch::Request#request_id 2015-02-20 20:43:39 -02:00
Rafael Mendonça França
08cec83233 Merge pull request #18218 from brainopia/fix_match_shorthand_in_routes
Don't use shorthand match on routes with inappropriate symbols
2015-02-20 19:28:05 -02:00
Sean Griffin
f3186093d8 Merge pull request #18665 from sgrif/sg-test-route-all
Allow `method: "all"` as a valid routing test option
2015-02-20 09:44:09 -07:00
Evan Phoenix
e002a68a4e Make the helpers a required argument 2015-02-19 15:11:08 -08:00
Evan Phoenix
43dae99645 Cache url_helpers instead of creating each time
This has 2 effects:

1. RoutesProxy is CRAZY faster because it's no longer creating a new
Module each time method_missing is hit.
2. It bypasses an existing bug in ruby that makes `class << obj` unsafe
to be used in threading contexts.
2015-02-19 14:20:56 -08:00
eileencodes
95ee93892a Freeze strings to reduce allocations in integration tests
Moves `X-Request-ID`, `action_dispatch.request_id` and
`HTTP_X_REQUEST_ID` strings to constants and freezes them.

We are freezing these strings to reduce the number of allocations in
Rails integration tests. The tests are spending a lot of time in GC and
this reduces the amount of time spent from 12% to 9% (in combination
with Rack PR that also freezes some strings).

Number of allocations before this change: 1030722
Number of allocations after this change: 967722
2015-02-18 18:54:37 -05:00
eileencodes
e334417b78 Reduce the number of times #clean_path_info is called
It's unnecessary to call `#clean_path_info`. It doesn't need to be
called on the path with each extension. This reduces allocations to
`Rack::Utils` in integration tests.

Before `#clean_path_info` from `Rack::Utils` (line 622) was number 2
in top 5 allocations:
```
[["rack/lib/rack/utils.rb", 499, :T_STRING], [51034, 4539, 71559, 0, 12, 1791120]]
[["rack/lib/rack/utils.rb", 662, :T_STRING], [33012, 0, 27930, 0, 1, 1226009]]
[["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [29998, 0, 25380, 0, 1, 3230600]]
[["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [29996, 0, 25378, 0, 2, 1113840]]
[["rails/activesupport/lib/active_support/notifications/instrumenter.rb", 52, :T_HASH], [29994, 147, 27014, 0, 11, 4897784]]
```

After `#clean_path_info` from `Rack::Utils` (line 622) does not appear
in the top 5 highest allocations:
```
[["rack/lib/rack/utils.rb", 499, :T_STRING], [47617, 2414, 68969, 0, 12, 1667360]]
[["rack/lib/rack/body_proxy.rb", 34, :T_ARRAY], [28230, 0, 26060, 0, 1, 1046800]]
[["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [28208, 0, 26042, 0, 1, 3034096]]
[["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [28204, 0, 26040, 0, 1, 1046080]]
[["rails/activesupport/lib/active_support/callbacks.rb", 165, :T_DATA], [28200, 0, 26046, 0, 2, 3451800]]
```
2015-02-18 18:54:26 -05:00
Rafael Mendonça França
d0303d03a9 Try only to decode strings
This approach will avoid us to check for NoMethodError when trying to
decode
2015-02-18 19:37:56 -02:00
Rafael Mendonça França
fb876b8a2c Merge pull request #18917 from lautis/non-string-csrf-token
Handle non-string authenticity tokens
2015-02-18 19:37:24 -02:00
Robin Dupret
1747c4e2ce Tiny documentation edits [ci skip] 2015-02-15 19:19:04 +01:00
Arthur Neves
2ed39424db Implement http_cache_forever to ActionController
Add http_cache_forever to ActionController, so we can cache results
forever.
Things like static pages are a good candidate for this type of caching.

This cache only controls caching headers, so it is up to the browser to
cache those requests.
2015-02-15 11:36:36 -05:00
Arthur Neves
62133326df Add missing comma 2015-02-13 13:25:13 -05:00
Guo Xiang Tan
899e10f562 Correct module name in deprecation message. 2015-02-13 19:06:25 +08:00
Guo Xiang Tan
aca4c82d95 Improve deprecation message. 2015-02-13 15:30:13 +08:00
Guo Xiang Tan
dbf38a06f4 Do not recommend xhr since it is going to be deprecated. 2015-02-13 15:22:58 +08:00
Andrew Lazarus
85842c553d require rack/utils in exception_wrapper 2015-02-12 14:56:35 -08:00
Ville Lautanala
bf067b41e5 Handle non-string authenticity tokens
Non-string authenticity tokens raised NoMethodError when decoding the
masked token.
2015-02-12 22:24:45 +02:00
Aaron Patterson
b03b09dc86 remove meta programming
there's really no benefit here.  It's the same number of lines without
the meta programming and is faster
2015-02-12 12:11:19 -08:00
Aaron Patterson
4cf3b8ac47 there is always an integration session, so remove the check 2015-02-12 12:09:03 -08:00