Commit Graph

12035 Commits

Author SHA1 Message Date
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
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
eileencodes
e1e2b54e85 Bump rack-test to fix nil values being sent to parse_nested_query
I found that nil values were being incorrectly sent to
`parse_nested_query` in Rack. Originally it was thought that Rails was
doing something incorrect but it was actually rack-test. This was fixed
in brynary/rack-test@4a4b2c1 and is no longer an issue. This commit
bumps rack-test in Rails so changes to Rack don't cause failures.

See rack/rack#813 for more information.
2015-03-01 16:58:15 -05: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
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
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
Yves Senn
71fc789239 add CHANGELOG for f6e293ec54f02f83cdb37502bea117f66f87bcae. [ci skip] 2015-02-25 18:03:20 +01: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
Rafael Mendonça França
68a2a67116 Merge pull request #18948 from kaspth/automatic-collection-caching
Merge multi_fetch_fragments.
2015-02-25 11:54:07 -03:00
Jeremy Kemper
f4f94081dd Add a failing test demonstrating regression with HEAD requests to Rack apps, re #18764 2015-02-24 15:59:21 -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
efc6d49114 Use other controller instead of sharing the controller 2015-02-24 14:59:28 -03:00
Rafael Mendonça França
f6a31f5321 Make TestController available to all test classes 2015-02-24 14:14:15 -03: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
Santiago Pastorino
88b334ec69 Merge pull request #19038 from tchandy/cleaning_actionpack_tests
Cleaning actionpack tests
2015-02-23 17:39:20 -02: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
Yves Senn
e71f5dad4e some indenting and punctuation fixes. [ci skip] 2015-02-23 16:54:40 +01: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
Thiago Pradi
3c181f66a3 Removing old helper that was necessary for compatibility with Ruby 1.8.x 2015-02-22 23:42:51 -03:00
Thiago Pradi
48a0995c7e Removing unused constants from abstract_unit 2015-02-22 23:42:50 -03:00
Thiago Pradi
2b88f65061 Removing unused controller from abstract_unit 2015-02-22 23:42:50 -03:00
Thiago Pradi
71b73b01a6 Removing unused template 2015-02-22 23:42:50 -03:00
Kasper Timm Hansen
11644fd0ce Collections automatically cache and fetch partials.
Collections can take advantage of `multi_read` if they render one template
and their partials begin with a cache call.

The cache call must correspond to either what the collections elements are
rendered as, or match the inferred name of the partial.

So with a notifications/_notification.html.erb template like:

```ruby
<% cache notification %>
  <%# ... %>
<% end %>
```

A collection would be able to use `multi_read` if rendered like:

```ruby
<%= render @notifications %>
<%= render partial: 'notifications/notification', collection: @notifications, as: :notification %>
```
2015-02-21 16:06:57 +01:00
Carlos Antonio da Silva
08d9c7532c Fix changelog indent [ci skip] 2015-02-20 20:52:20 -02: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
Aaron Patterson
303567e554 lazily create the integration session
now we don't have to call reset! everywhere
2015-02-12 12:04:23 -08:00
Aaron Patterson
fa63448420 use before_setup to set up test instance variables 2015-02-12 11:51:52 -08:00
eileencodes
0acd4a5776 Skip url_helpers instead of caching, speed up integration tests
We shouldn't cache if it's not absolutely necessary. Removes
route caching and instead skips using the `url_helpers` is the
integration test session doesn't require it. Benchmark ips on
integration and controller index method tests below.

Without any caching or changes to `#url_helpers`:
```
Calculating -------------------------------------
INDEX: Integration Test
                        71.000  i/100ms
INDEX: Functional Test
                        99.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        728.878  (± 8.0%) i/s -      3.692k
INDEX: Functional Test
                          1.015k (± 6.7%) i/s -      5.148k

Comparison:
INDEX: Functional Test:     1015.4 i/s
INDEX: Integration Test:      728.9 i/s - 1.39x slower
```

With caching on `#url_helpers`:
```
Calculating -------------------------------------
INDEX: Integration Test
                        74.000  i/100ms
INDEX: Functional Test
                        99.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        752.377  (± 6.9%) i/s -      3.774k
INDEX: Functional Test
                          1.021k (± 6.7%) i/s -      5.148k

Comparison:
INDEX: Functional Test:     1021.1 i/s
INDEX: Integration Test:      752.4 i/s - 1.36x slower
```

Afer removing the caching and bypassing the `url_helpers` when not
necessary in the session:
```
Calculating -------------------------------------
INDEX: Integration Test
                        87.000  i/100ms
INDEX: Functional Test
                        97.000  i/100ms
-------------------------------------------------
INDEX: Integration Test
                        828.433  (± 6.4%) i/s -      4.176k
INDEX: Functional Test
                        926.763  (± 7.2%) i/s -      4.656k

Comparison:
INDEX: Functional Test:      926.8 i/s
INDEX: Integration Test:      828.4 i/s - 1.12x slower
```
2015-02-12 14:48:14 -05:00
Rafael Mendonça França
76f6524538 Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
2015-02-12 15:39:17 -02:00
yuuji.yaginuma
697688663f fix typo in fresh_when example [ci skip] 2015-02-12 16:54:01 +09:00
claudiob
050fda0206 Accept a collection in fresh_when and stale?
The methods `fresh_when` and `stale?` from ActionController::ConditionalGet
accept a single record as a short form for a hash. For instance

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(@article)
  end
```

is just a short form for:

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(etag: @article, last_modified: @article.created_at)
  end
```

This commit extends `fresh_when` and `stale?` to also accept a collection
of records, so that a short form similar to the one above can be used in
an `index` action. After this commit, the following code:

```ruby
def index
  @article = Article.all
  fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at))
end
```

can be simply written as:

```ruby
def index
  @article = Article.all
  fresh_when(@articles)
end
```
2015-02-10 17:08:44 -08:00
claudiob
c7331e057b Fix wrong kwarg "record" from #18872
PR #18772 changed the parameters of `stale?` to use `kwargs`.
[As for this comment](https://github.com/rails/rails/pull/18872/files#r24456288)
the default value for the `etag` parameter should be `record`, not `nil`.

This commit fixes the code and introduces a test that:

- passed before #18872
- fails on the current master (after #18772)
- passes again after setting the default value of `etag` to `record`.
2015-02-10 17:02:24 -08:00
Kasper Timm Hansen
7a78c25123 Convert stale? and fresh_when to use keyword arguments. 2015-02-10 23:01:47 +01:00
Terence Sun
b9c63b0aae Explicitly ignored wildcard verbs from head_routes
In match_head_routes, deleted the routes in which request.request_method was empty (matches all HTTP verbs) when responding to a HEAD request. This prevents catch-all routes (such as Racks) from intercepting the HEAD request.

Fixes #18698
2015-02-08 12:03:56 -05:00
Rafael Mendonça França
35e2255b7a Merge pull request #18771 from kirs/deprecate-xhr
Migrating xhr methods to keyword arguments syntax
2015-02-05 18:27:47 -02:00
Sean Griffin
4a62724c59 RouteSet should not be listed in the public API [ci skip]
The use of `# :startdoc:` inside of the class was overriding the
outer-most `# :nodoc:`, causing it to be listed in the documented API.
2015-02-03 11:52:09 -07:00
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
Andrew White
226cd8a094 Cache url_helpers separately for mailers
The commit 3b63780 re-introduced url helper caching but we need to
cache a separate module for Action Mailer without paths.
2015-02-01 22:50:41 +00:00
eileencodes
3b637802b2 Cache url_helpers
`url_helpers` used to be memoized. This was lost in a refactoring and
this PR adds it back. We noticed this while investigating why
integration tests are slower than controller tests.
2015-02-01 14:33:53 -08:00
Aaron Patterson
e6d8f435a9 Merge pull request #18721 from sj26/pre-discard-flash
Pre-discard flash messages
2015-02-01 08:58:11 -08:00
Andrew White
bf1716bc61 Merge pull request #18769 from gsamokovarov/exception-wrapper-windows-paths
Show proper traces on Windows for the error pages
2015-02-01 16:56:40 +00:00
Kir Shatrov
b19999f3a7 Migrating xhr methods to keyword arguments syntax
in `ActionController::TestCase` and
`ActionDispatch::Integration`

Old syntax:

    `xhr :get, :create, params: { id: 1 }`

New syntax example:

    `get :create, params: { id: 1 }, xhr: true`
2015-02-01 16:07:42 +03:00
Yves Senn
e374db2371 Merge pull request #18759 from yuki24/remove-warning
✂️ warning from controller renderer test
2015-02-01 11:44:12 +01:00
Genadi Samokovarov
872e22c603 Show proper traces on Windows for the error pages
This is an issue brought up by @daniel-rikowski in rails/web-console#91.

Citing his PR proposal here:

> Prior to this, backtrace lines were simply split by a single colon.
>
> Unfortunately that is also the drive letter delimiter in Windows paths
> which resulted in a lot of empty source fragments of "C:0". ("C" from
> the drive letter and 0 from "/path/to/rails/file.rb:16".to_i)
>
> Now the trace line is split by the first colon followed by some digits,
> which works for both Windows and Unix path styles.

Now, the PR was sent against web-console, because of the templates copy
issue we used to had. Instead of bothering the contributor to reopen the
issue against upstream Rails itself, I will make sure he gets the credit
by putting his name in [rails-contributors/hard_coded_authors.rb][].

  [rails-contributors/hard_coded_authors.rb]: (https://github.com/fxn/rails-contributors/blob/master/app/models/names_manager/hard_coded_authors.rb).
2015-02-01 12:00:18 +02:00
robertomiranda
ce8efcf296 Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846
ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
2015-01-31 23:12:41 -05:00
Yuki Nishijima
1bb1b9e8cb ✂️ warning from controller renderer test
rails/actionpack/test/controller/renderer_test.rb:89: warning: possible reference to past scope - defaults
2015-01-31 17:48:55 -08:00
Juanito Fatas
2e62d53c2f Fix a typo in deprecation warning. #process takes method instead of http_method. 2015-01-31 20:58:08 +08:00
Juanito Fatas
8cd115488c [ci skip] Document format parameter of process method in AC test_case. 2015-01-31 20:52:17 +08:00
Yves Senn
afe402dac7 unify CHANGELOG format. [ci skip] 2015-01-31 11:54:00 +01:00
Yves Senn
5170c11c97 fix typo in _filter deprecation message. [ci skip] 2015-01-30 14:01:58 +01:00
Samuel Cochran
3f528e371c Migrate old flash behaviour 2015-01-30 09:47:03 +11:00
Rafael Mendonça França
50318f5d7e Remove duplicated tests 2015-01-29 19:25:57 -02:00
Rafael Mendonça França
bb6fe7e73a Consistent usage of spaces in hashes across our codebase 2015-01-29 12:19:41 -02:00
Rafael Mendonça França
7814f901e1 Use fixed fonts only in the name of the parameter 2015-01-29 12:19:21 -02:00
Rafael Mendonça França
0eb3ba0e65 Improve CHANGELOG 2015-01-29 11:52:10 -02:00
Kir Shatrov
baf14ae513 Switch to kwargs in ActionController::TestCase and ActionDispatch::Integration
Non-kwargs requests are deprecated now.
Guides are updated as well.

`post url, nil, nil, { a: 'b' }` doesn't make sense.
`post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
2015-01-29 14:44:46 +02:00
Samuel Cochran
f7adb34999 Discard from flash before persisting in session 2015-01-29 23:18:55 +11:00
Samuel Cochran
3a102d0528 Fix flash remaining after last flash deleted
Inside a controller functional test after the last flash is deleted it
still persists the flash because to_session_value is nil. We should
delete it from the session when the serialized version is nil, same as
the flash middleware.
2015-01-29 23:00:44 +11:00
Tekin Suleyman
db870f222e Preserve default url options when generating URLs
Fixes an issue that would cause default_url_options to be lost when generating
URLs with fewer positional arguments than parameters in the route definition.
2015-01-28 21:15:52 +00:00
Rafael Mendonça França
39bcbaece6 Just assert the deprecation of one method 2015-01-28 18:50:11 -02:00
Rafael Mendonça França
7d9c5c1653 Add CHANGELOG entry 2015-01-28 18:50:01 -02:00
Rafael Mendonça França
643f08beeb Merge pull request #18693 from aditya-kapoor/deprecate_via_redirect
Deprecate *_via_redirect integration test methods
2015-01-28 18:34:39 -02:00
Aditya Kapoor
751f752b43 Deprecate *_via_redirect integration test methods 2015-01-28 17:23:30 +05:30
Guillermo Iguaran
36082a6204 Merge pull request #18666 from cheunghy/auth_check_nil
Fixed undefined method error when doing http basic authentication.
2015-01-28 00:00:17 -05:00
Aaron Patterson
1fb9e6eff7 improve performance of integration tests.
I found delegate to be a bottleneck during integration tests.  Here is
the test case:

```ruby
require 'test_helper'

class DocumentsIntegrationTest < ActionDispatch::IntegrationTest
  test "index" do
    get '/documents'
    assert_equal 200, response.status
  end
end

Minitest.run_one_method(DocumentsIntegrationTest, 'test_index')
StackProf.run(mode: :wall, out: 'stackprof.dump') do
  3000.times do
    Minitest.run_one_method(DocumentsIntegrationTest, 'test_index')
  end
end
```

Top of the stack:

```
[aaron@TC integration_performance_test (master)]$ stackprof stackprof.dump
==================================
  Mode: wall(1000)
  Samples: 23694 (7.26% miss rate)
  GC: 1584 (6.69%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
      7058  (29.8%)        6178  (26.1%)     block in Module#delegate
       680   (2.9%)         680   (2.9%)     ActiveSupport::PerThreadRegistry#instance
       405   (1.7%)         405   (1.7%)     ThreadSafe::NonConcurrentCacheBackend#[]
       383   (1.6%)         383   (1.6%)     Set#include?
       317   (1.3%)         317   (1.3%)     ActiveRecord::Base.logger
       281   (1.2%)         281   (1.2%)     Rack::Utils::HeaderHash#[]=
       269   (1.1%)         269   (1.1%)     ActiveSupport::Notifications::Fanout::Subscribers::Evented#subscribed_to?
       262   (1.1%)         262   (1.1%)     block (4 levels) in Class#class_attribute
       384   (1.6%)         246   (1.0%)     block (2 levels) in Class#class_attribute
```

According to @eileencodes's tests, this speeds up integration tests so
that they are only 1.4x slower than functional tests:

Before:

  INDEX: Integration Test:      153.2 i/s - 2.43x slower

After:

  INDEX: Integration Test:      275.1 i/s - 1.41x slower
2015-01-27 16:29:18 -08:00
brainopia
572bbab2e6 Improve shorthand matching for routes
Shorthand route match is when controller and action are taken literally from path.
E.g.
get '/foo/bar' # => will use 'foo#bar' as endpoint
get '/foo/bar/baz' # => will use 'foo/bar#baz' as endpoint

Not any path with level two or more of nesting can be used as shortcut.
If path contains any characters outside of /[\w-]/ then it can't be
used as such.

This commit ensures that invalid shortcuts aren't used.

':controller/:action/postfix' - is an example of invalid shortcut
that was previosly matched and led to exception:
"ArgumentError - ':controller/:action' is not a supported controller name"
2015-01-25 03:07:27 +03:00
Zhang Kai Yu
98277d1398 Fixed undefined method error when doing authentication. 2015-01-24 07:18:45 +08:00
Zhang Kai Yu
3e02cdc872 Add test for HTTP basic authentication when no credential is given. 2015-01-24 07:17:11 +08:00