Commit Graph

12035 Commits

Author SHA1 Message Date
Sean Griffin
6cf671b61e Allow method: "all" as a valid routing test option
This allows the test to mirror the production code, since `via: :all` is
a valid option. The behavior in 4.1 did not actually test that it
matched all verbs, but instead defaulted to testing for "GET". This
implementation aims to better handle the intention of passing "all".

What will actually be asserted doesn't quite match up with the generated
route, since it appears to just not create a constraint on the method.
However, I don't think that we can easily test the lack of that
constraint. Testing each of the main 4 HTTP verbs seems to be a
reasonably close approximation, which should be sufficient for our
needs.

Fixes #18511.
2015-01-23 16:03:38 -07:00
Kasper Timm Hansen
d3211d76ce Speed up normalize_keys by removing dup step.
Previously env was duplicated and then had it's keys mutated. This iterates through
the hash twice.
Using `transform_keys`, duplication and key mutation is a single iteration.

`convert_symbols` was renamed to `http_header_format`.
2015-01-22 17:35:19 +01:00
Rafael Mendonça França
e36ecf4d77 Merge pull request #18546 from brainopia/action_view_render
A shortcut to setup controller environment
2015-01-22 12:09:32 -02:00
brainopia
656628961c Add ActionController::Base.render 2015-01-22 01:02:13 +03:00
brainopia
801e399e42 Add ActionController::Renderer
Render arbitrary templates outside of controller actions
2015-01-22 01:02:11 +03:00
brainopia
47b6fe0682 Add ActionController#build_with_env
To have an easier way to setup a controller
instance with custom environment
2015-01-22 00:26:06 +03:00
brainopia
685142e4f4 Support :assigns option when rendering with controllers/mailers. 2015-01-22 00:25:50 +03:00
brainopia
ee6e13f3da Add ActionController::Metal#set_request!
Add `ActionController::Metal#set_request!` to set a request
on controller instance without calling dispatch.
2015-01-21 23:53:38 +03:00
Santiago Pastorino
53919bbfd2 Merge pull request #18483 from rono23/fix-name_for_action-in-routing
Fix name_for_action in routing
2015-01-19 00:52:40 -02:00
rono23
8a8dac80bb Fix name_for_action in routing 2015-01-19 10:32:27 +09:00
Vijay Dev
3f96b6973b Merge branch 'master' of github.com:rails/docrails 2015-01-15 07:28:21 +00:00
Vipul A M
822dc9133e Extract Date header to string constant in Http Response, similar to other headers 2015-01-14 12:37:58 +05:30
Santiago Pastorino
da175a2b46 Relax Rack dependency
Rack is very carefully released, we should be able to upgrade minor
versions without much effort. We are a bunch of Rails core who are also
Rack core members so there won't be any issue with that. And in case
there's something wrong, we should fix on both sides.
Even though, doesn't seem like we will have a 1.7 version, this will be
useful as an example for when we go with Rack 2.0. We should ~> 2.0.
2015-01-12 15:32:33 -02:00
claudiob
7d493a6020 Remove unused AV fixtures from AP tests
When `render` was moved from ActionPack to ActionView in acc8e259,
some fixtures required by the tests were duplicated, but they are
actually only required by ActionView tests.

To give one example, `double_render` is already defined [in the AV tests](72139d8d31/actionview/test/actionpack/controller/render_test.rb (L407))
and is never used in the ActionPack tests.
2015-01-11 13:01:13 -08:00
Rafael Mendonça França
7b47f422cf Merge pull request #18435 from kuldeepaggarwal/f-remove-unnecessary-require
No need of requiring `rbconfig`, it is by-default loaded
2015-01-11 16:13:22 -02:00
yuuji.yaginuma
e3be421cc1 remove autoload HideActions, no longer exist 2015-01-11 21:13:59 +09:00
Kuldeep Aggarwal
90aef23e38 No need of requiring rbconfig, it is by-default loaded 2015-01-10 20:27:18 +05:30
Yves Senn
a7621d7d53 formatting pass over CHANGELOGs. [ci skip] 2015-01-10 12:17:57 +01:00
Yves Senn
a94f8e71d2 Merge pull request #18423 from jone/remove-default-header
Default headers, removed in controller actions, will not be reapplied to the test response
2015-01-09 17:01:31 +01:00
Jonas Baumann
0739480f45 Default headers, removed in controller actions, will not be reapplied to the test response. 2015-01-09 16:55:02 +01:00
Abdelkader Boudih
7644a99d90 Deprecate all *_filter callbacks in favor of *_action callbacks 2015-01-08 20:52:36 +00:00
Rafael Mendonça França
b8e83ce1c5 Merge pull request #18404 from claudiob/rebase-14549
Add test case and documentation for skip_before_filter.
2015-01-08 18:08:02 -02:00
David Heinemeier Hansson
9af5f33a16 Fix the example (for realz) 2015-01-08 11:18:06 -08:00
David Heinemeier Hansson
6b9a973154 Fix the example 2015-01-08 11:17:03 -08:00
Josef Šimánek
0074bbb07b Add prepend option to protect_from_forgery. 2015-01-08 19:47:19 +01:00
claudiob
9a25603d0a Add test/doc for :if/:except in skip_before_action
The new test/docs further explain the conflicts that can happen when
mixing `:if`/`:unless` options with `:only`/`:except` options in
`skip_before_action`.

The gist is that "positive" filters always have priority over negative
ones.

The previous commit already showed that `:only` has priority over `:if`.

This commit shows that `:if` has priority over `:except`.

For instance, the following snippets are equivalent:

```ruby
skip_before_action :some_callback, if: -> { condition }, except: action
```

```ruby
skip_before_action :some_callback, if: -> { condition }
```
2015-01-08 09:30:31 -08:00
Lauro Caetano
ae9f803c5d Add test case and documentation for skip_before_filter.
Test case for using skip_before_filter with the options :only and :if
both present. In this case, the :if option will be ignored and :only
will be executed.

Closes #14549 (the commit was cherry-picked from there).
2015-01-08 09:13:45 -08:00
brainopia
08d3f0e3b3 Remove ActionController::HideActions (closes #18336) 2015-01-06 23:40:45 +03:00
claudiob
283326cc61 Better examples for fresh_when and stale?
It is clearer and closer to reality to use `@article.updated_at` as
the `:last_modified` parameter of `fresh_when` and `stale?`.

Using `@article.created_at` would result in the cache never expiring,
since the creation timestamp never changes.

[ci skip]
2015-01-06 12:32:27 -08:00
Lindsey Bieda
c6117b6be1 Changing sets -> set
Updating some minor grammar issue.
2015-01-06 13:08:34 -05:00
Josef Šimánek
734306612e Improve protect_from_forgery documentation. [ci skip]. 2015-01-06 00:37:37 +01:00
Rafael Mendonça França
f8e36d49f4 Merge pull request #18341 from aditya-kapoor/remove-unneeded-checks
remove unneeded check since /_one_time_conditions/ is not present anymore.
2015-01-05 09:47:30 -03:00
brainopia
e275479ce5 Reset template assertions without warnings 2015-01-05 15:06:42 +03:00
Aditya Kapoor
21dfe89ac7 remove unneeded check since /_one_time_conditions/ is removed 2015-01-05 16:52:19 +05:30
Josef Šimánek
24d48dfc1a Document all options for protect_from_forgery.
[ci skip]
2015-01-04 23:59:11 +01:00
Carlos Antonio da Silva
cf6b13b2be Remove unused require
This was used by the respond_to/respond_with implementation on this
file, which is now extracted to the responders gem.
2015-01-04 18:26:36 -02:00
Carlos Antonio da Silva
afd5e9a7ff Remove respond_to/respond_with placeholder methods
This functionality has been extracted to the responders gem.
2015-01-04 18:22:09 -02:00
Rafael Mendonça França
758e223c45 Remove Struct#to_h backport 2015-01-04 16:20:18 -03:00
Rafael Mendonça França
21f02f3485 Remove some comments about Ruby 1.9 behaviors 2015-01-04 15:55:28 -03:00
Rafael Mendonça França
bf7b8c193f Remove unneeded requires
These requires were added only to change deprecation message
2015-01-04 12:11:03 -03:00
Rafael Mendonça França
92e27d30d8 Remove deprecated assertion files 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
34e380764e Remove deprecated usage of string keys in URL helpers 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
e4e1fd7ade Remove deprecated only_path option on *_path helpers 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
d282125a18 Remove deprecate *_path helpers in email views 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
2cc91c37bc Remove deprecated NamedRouteCollection#helpers 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
1f3b0a8609 Remove deprecated support to define routes with :to option that
doesn't contain `#`
2015-01-04 11:58:41 -03:00
Rafael Mendonça França
4b19d5b7bc Remove deprecated ActionDispatch::Response#to_ary 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
7676659633 Remove deprecated ActionDispatch::Request#deep_munge 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
7fe7973cd8 Remove deprecated ActionDispatch::Http::Parameters#symbolized_path_parameters 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
e4cfd353a4 Remove deprecated option use_route in controller tests 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
4591b0fc04 Merge pull request #17227 from claudiob/explicitly-abort-callbacks
Introduce explicit way of halting callback chains by throwing :abort. Deprecate current implicit behavior of halting callback chains by returning `false` in apps ported to Rails 5.0. Completely remove that behavior in brand new Rails 5.0 apps.

Conflicts:
	railties/CHANGELOG.md
2015-01-03 17:22:20 -03:00
Robin Dupret
9b9ec0ded4 Fix a few typos [ci skip] 2015-01-03 16:36:33 +01:00
Vijay Dev
4b9dba99d6 Merge branch 'master' of github.com:rails/docrails 2015-01-03 14:58:17 +00:00
Rafael Mendonça França
3456d543eb Merge pull request #10380 from JonRowe/test_all_domain_2_letter_tld
Assert that 2 letter tlds with 3 letter domain names work when option specified.
2015-01-02 21:27:38 -03:00
claudiob
2386daabe7 Throw :abort halts default CallbackChains
This commit changes arguments and default value of CallbackChain's :terminator
option.

After this commit, Chains of callbacks defined **without** an explicit
`:terminator` option will be halted as soon as a `before_` callback throws
`:abort`.

Chains of callbacks defined **with** a `:terminator` option will maintain their
existing behavior of halting as soon as a `before_` callback matches the
terminator's expectation. For instance, ActiveModel's callbacks will still
halt the chain when a `before_` callback returns `false`.
2015-01-02 15:31:55 -08:00
Rafael Mendonça França
48deeab90a Merge pull request #8740 from amatsuda/missing_source_file
replace use of MissingSourceFile with LoadError

Conflicts:
	activesupport/test/core_ext/load_error_test.rb
2015-01-02 19:19:59 -03:00
Rafael Mendonça França
2d743b528c Merge pull request #17978 from kommen/fixed-pr-14903
Ensure append_info_to_payload is called even if an exception is raised.

Conflicts:
	actionpack/CHANGELOG.md
2015-01-02 14:16:15 -03:00
brainopia
95333e1317 Integration requests should work in contexts without setup and teardown 2015-01-02 16:52:32 +03:00
Robin Dupret
24637e577c Merge pull request #18271 from arunagw/change-copyright-year
Update copyright notices to 2015 [ci skip]
2015-01-01 00:08:17 +01:00
Robin Dupret
7ef7f1cc15 Correctly use the response's status code calling head
Commit 20fece1 introduced the `_status_code` method to fix calls to
`head :ok`. This method has been added on both ActionController::Metal
and ActionDispatch::Response.

As for the latter, this method is just equivalent to the `response_code`
one so commit aefec3c removed it from the `Reponse` object so call to
the `_status_code` method on an ActionController::Base instance would be
handled by the `Metal` class (which `Base` inherits from) but the status
code is not updated according to the response at this level.

The fix is to actually rely on `response_code` for ActionController::Base
instances but this method doesn't exist for bare Metal controllers so we
need to define it.
2014-12-31 16:37:35 +01:00
Arun Agrawal
4de18d0ead Update copyright notices to 2015 [ci skip] 2014-12-31 08:34:14 +01:00
Aaron Patterson
4080dd2f24 stop referencing env in url_for
encapsulate env in the request so that we can eventually move away from
the env hash
2014-12-30 15:18:20 -08:00
Aaron Patterson
87a7591064 use methods on the request rather than direct hash access
this will help decouple us from using the rack env hash
2014-12-30 14:48:10 -08:00
Prathamesh Sonpatki
75757c5c3b Remove single space response body for head request
- The single space response was added due to a bug in safari
  in cb0f8fda96
  and
  807df4fcf0.
- This was removed from the `render nothing: true` in
  https://github.com/rails/rails/pull/14883.
- Removing it from response of :head also. As :head is more obvious
  alternative to call `render nothing:
  true`(http://guides.rubyonrails.org/layouts_and_rendering.html#using-head-to-build-header-only-responses),
  removing it from head method also.
- Closes #18253.
2014-12-30 20:50:23 +05:30
Rafael Mendonça França
0c070ae568 Merge pull request #18251 from tjgrathwell/fix-polymorphic-routes-to-model
Fix form_for to work with objects that implement to_model
2014-12-30 11:23:47 -03:00
Travis Grathwell
3efd90ac5b Fix form_for to work with objects that implement to_model
Previously, if you tried to use form_for with a presenter object
that implements to_model, it would crash in
action_dispatch/routing/polymorphic_routes.rb when asking the presenter
whether it is .persisted?

Now, we always ask .persisted? of the to_model object instead.

This seems to been an issue since 1606fc9d840da869a60213bc889da6fcf1fdc431

Signed-off-by: Eugenia Dellapenna <eugenia.dellapenna@gmail.com>
2014-12-29 18:12:03 -08:00
Zachary Scott
241ccaef88 Move longer form example from integration guide to api reference, below an
existing example. [ci skip]

My reasoning is that this is probably too much information for the complete
Rails testing guide, as we're trying to cover testing all aspects of the
framework.
2014-12-29 17:29:47 -08:00
Robin Dupret
73fe108d70 Minor documentation edits [ci skip] 2014-12-28 22:55:09 +01:00
Guillermo Iguaran
edaab4dbe8 Merge pull request #18209 from claudiob/bump-to-2-2
Require Ruby 2.2 for Rails 5.0
2014-12-28 16:39:39 -05:00
Ben Prew
75df8b9a77 Update example test documentation
Example does not work with session headers, should use request headers. [ci skip]
2014-12-28 13:10:01 -08:00
claudiob
d3b098b828 Require Ruby 2.2 for Rails 5.0
Stems from [this comment](https://github.com/rails/rails/pull/18203#issuecomment-68138096) by @robin850
and by the blog post http://weblog.rubyonrails.org/2014/12/19/Rails-4-2-final
2014-12-26 13:53:09 +01:00
claudiob
4761d81923 Remove ActionController::ModelNaming
The methods in these modules are not used anywhere. They used to be
invoked in polymorphic_routes.rb but their usage was removed in e821045.

What is your opinion about removing these methods?

They do belong to the public API, but in reality their code has already been duplicated to ActionView::ModelNaming, since they are used by methods like `dom_id` and `dom_class` to associated records with DOM elements (in
ActionView).

Please tell me if you think that removing this module is a good idea and,
in that case, if the PR is okay as it is, or you'd rather start by showing
a deprecation message, and remove the module in Rails 5.1.
2014-12-25 00:30:46 +01:00
Vipul A M
7b2728cac1 - Removed unused parameter to cookie serialize method and fixed usage of the same elsewhere 2014-12-24 18:45:55 +05:30
Yves Senn
0587070391 cleanup CHANGELOGs. [ci skip] 2014-12-23 08:56:17 +01:00
claudiob
bea61d6670 Better docs for AbstractController
Fixes internal links, adds examples and set fixed-width fonts.

[ci skip]
2014-12-22 03:53:48 +01:00
Vijay Dev
15590c1a2a Merge branch 'master' of github.com:rails/docrails 2014-12-20 14:26:21 +00:00
Arthur Nogueira Neves
e4f015e4e8
Merge pull request #18102 from arthurnn/nodoc_constant
Add nodoc to some constants [skip ci]
2014-12-19 18:22:46 -05:00
Godfrey Chan
111f2f4422 Use released rack
`rack.version` was bumped in 28e77c710a
2014-12-19 01:26:19 -08:00
Godfrey Chan
5923ee6fe0 Revert "Merge pull request #18003 from sikachu/permit_all_parameters-thread-safety"
This reverts commit da5cc10e945552da54234f858470238a3fc36767.

Fixes #18091

See also https://github.com/rails/rails/pull/18003#commitcomment-9030909
2014-12-19 01:14:26 -08:00
claudiob
78ae8eebe5 Add docs for ActionDispatch::Http::URL methods
Add docs for `extract_domain`, `extract_subdomains`, `extract_subdomain`.

Add doc examples for `url`, `protocol`, `raw_host_with_port`, `host`,
`host_with_port`, `port`, `standard_port`, `standard_port?`, `optional_port`,
`port_string`.

[ci skip]
2014-12-18 15:31:45 -08:00
Zachary Scott
3f6a472d92 Fix typo in nodoc should be :nodoc: for RDoc to parse correctly 2014-12-17 17:03:29 -08:00
Rafael Mendonça França
e745ae297f Merge pull request #17995 from jethroo/fix/assert_template_with_unsupported_layout_type
assert template should raise ArgumentError for unsupported layout types
2014-12-16 18:35:38 -02:00
Carsten Wirth
7ff31feb14 adding that assert_template with :layout will raise ArgumentError for unknown layout type 2014-12-16 19:30:52 +01:00
Rafael Mendonça França
3bdd110dfe Merge pull request #18052 from timoschilling/reset_variants
allow reseting of request variants
2014-12-16 15:06:01 -02:00
Timo Schilling
e1fb3483d6 allow reseting of request variants
The current implementation of `variants=` don't allow a resetting to nil, wich is the default value.

This results in the following code smell:
```ruby
case request.user_agent
when /iPhone/
  request.variants = :phone
when /iPad/
  request.variants = :ipad
end
```

With the ability to reset variants to nil, it could be:
```ruby
request.variants = case request.user_agent
when /iPhone/
  :phone
when /iPad/
  :ipad
end
```
2014-12-16 11:37:04 +01:00
claudiob
8dfa585db2 Remove misleading test: around_action return false
When an `around_action` does not `yield`, then the corresponding action is
*never* executed and the `after_` actions are *never* invoked.

The value returned by the `around_action` does not have any impact on this:
an `around_action` can "return" `true`, `false`, or `"pizza"`, but as long
as `yield` is not invoked, the corresponding action and after callbacks are
not executed.

The test suite for `ActionController::Callbacks` currently includes separate
tests to distinguish the cases in which a non-yielding `around_actions` returns
`true` or `false`.

In my opinion, having such tests is misleading, giving the impression that the
returned value might have some sort of impact, while it does not. At least
that's the impression I got when I read those tests.

For completeness, the tests were introduced 7 years ago by @NZKoz in e80fabb.
2014-12-15 16:36:50 -08:00
Chris Sinjakli
8f8ccb9901 Don't convert empty arrays to nils when deep munging params 2014-12-15 14:51:07 +00:00
Santiago Pastorino
ef99d4cd3e Merge pull request #18022 from agrobbin/url-helpers-optional-scopes
Allow URL helpers to work with optional scopes
2014-12-13 19:03:30 -02:00
Alex Robbin
a842c5c12d allow URL helpers to work with optional scopes 2014-12-13 15:52:41 -05:00
Nate Berkopec
d57d85a126 ParameterFilter shouldn't try to dup symbol keys 2014-12-13 15:34:59 -05:00
Tatiana Soukiassian
1a50be8231 Fix handling of positional url helper arguments when format is false
There is no need to subtract one from the path_params size when there is
no format parameter because it is not present in the path_params array.

Fixes #17819.
2014-12-13 15:42:15 +00:00
Rafael Mendonça França
b64d89482a Merge pull request #18006 from sikachu/add-params-to_unsafe_h
Add AC::Parameters#to_unsafe_h
2014-12-12 23:58:46 -02:00
Prem Sichanugrist
61fff0e23b Add AC::Parameters#to_unsafe_h
As suggested in #16299([1]), this method should be a new public API for
retrieving unfiltered parameters from `ActionController::Parameters`
object, given that `Parameters#to_hash` will no longer work in Rails
5.0+ as we stop inheriting `Parameters` from `Hash`.

[1]: https://github.com/rails/rails/pull/16299#issuecomment-50220919
2014-12-12 18:52:10 +07:00
Prem Sichanugrist
0d975e289d Make AC::Params.permit_all_parameters thread safe
As discussed in #16299[1], this attribute is not thread safe and could
potentially create a security issue.

[1]: https://github.com/rails/rails/pull/16299#discussion_r15424533
2014-12-12 17:30:05 +07:00
Dieter Komendera
2fde159f6b Ensure append_info_to_payload is called even if an exception is raised.
See:
* https://github.com/rails/rails/pull/14903
* https://github.com/roidrage/lograge/issues/37

Some code by mxrguspxrt from #14903.
2014-12-10 22:13:13 +01:00
Rafael Mendonça França
d428242c86 Only check that it is a Rails application once
Also avoid using try since is_a? is faster for this case.
2014-12-08 15:42:55 -02:00
T.J. Schuck
ee65f48c26 Mounted Rack apps should have default named routes based on app name
This fixes a regression in 4.2.0 from 4.1.8.

https://github.com/rails/rails/pull/17823 fixed a similar regression regarding _explicitly_ named routes for a mounted Rack app, but there was another regression for the default value.

With a route like:

    Rails.application.routes.draw do
      mount Mountable::Web, at: 'some_route'
    end

The "Prefix" column of rake routes gives the following:

- 4.1.8:         mountable_web
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1:     [nothing]
- 4.2.0.rc2:     some_route   <- regression

This fixes the default to go back to being based off the name of the class like the docs specify: 785d04e310/actionpack/lib/action_dispatch/routing/mapper.rb (L558-L560)

Explicitly named routes still work correctly per https://github.com/rails/rails/pull/17823:

    Rails.application.routes.draw do
      mount Mountable::Web, at: 'some_route', as: 'named'
    end

- 4.1.8:         named
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1:     [nothing]
- 4.2.0.rc2:     named
2014-12-06 01:17:50 -05:00
Sergey Alekseev
198b1dd201 remove unused #optional_parts
This method was copied from journey at 56fee39c39 (diff-2cfaf53c860732fea8689d6f2002594bR78).
`grep -nr 'optional_parts' .`
2014-12-05 16:21:17 +03:00
Sergey Alekseev
db00c5b7a4 remove unused #generalized_table
This method wass copied from journey at 56fee39c39 (diff-d89de8881fc4b9f10cb3e4fc7b2463f3R53). However it looks the method was unused in journey at those point as well.
2014-12-05 16:09:03 +03:00
Tu Hoang
8ef51f64e5 Typo: Hello = Guten Tag (in German) 2014-12-05 12:54:15 +07:00
Rafael Mendonça França
2673a359e1 We don't need to call to_sym. Just compare the string 2014-12-04 15:24:16 -02:00
Rafael Mendonça França
dfa45ce7e1 Merge pull request #17792 from rockrep/master
allow 'all' for :domain option in addition to :all
2014-12-04 15:21:47 -02:00
Sergey Alekseev
d09bce96b4 remove unused #await_close
The method was added in 30d21dfcb7 (diff-5055d9f16b442adb1d2f0f65903a196bR141).
With the method call in 30d21dfcb7 (diff-cc7bb557df2247c0a42bc180fdb6eb05R47).
Later one more method call was added in 401787db4b (diff-cc7bb557df2247c0a42bc180fdb6eb05R183).
And both method calls were deleted in 3df07d093a (diff-cc7bb557df2247c0a42bc180fdb6eb05L47) and 3df07d093a (diff-cc7bb557df2247c0a42bc180fdb6eb05L189).

Just do `grep -nr 'await_close' .`.
2014-12-04 14:35:52 +03:00
claudiob
e428ddecec Remove "rescue" clause around "require 'openssl'"
Some `require 'openssl'` statements were surrounded by `rescue` blocks to deal with Ruby versions that did not support `OpenSSL::Digest::SHA1` or `OpenSSL::PKCS5`.

[As @jeremy explains](a6a0904fcb (commitcomment-8826666)) in the original commit:

> If jruby didn't have jruby-openssl gem, the require wouldn't work. Not sure whether either of these are still relevant today.

According to the [release notes for JRuby 1.7.13](http://www.jruby.org/2014/06/24/jruby-1-7-13.html):

> jruby-openssl 0.9.5 bundled

which means the above `rescue` block is not needed anymore.

All the Ruby versions supported by the current version of Rails provide those OpenSSL libraries, so Travis CI should also be happy by removing the `rescue` blocks.

---

Just to confirm, with JRuby:

    $ ruby --version #=> jruby 1.7.16.1 (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26 +jit [darwin-x86_64]
    $ irb
    irb(main):001:0> require 'openssl' #=> true
    irb(main):002:0> OpenSSL::Digest::SHA1 #=> OpenSSL::Digest::SHA1
    irb(main):003:0> OpenSSL::PKCS5 # => OpenSSL::PKCS5

And with Ruby 2.1:

    $ ruby --version #=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
    $ irb
    irb(main):001:0> require 'openssl' #=> true
    irb(main):002:0> OpenSSL::Digest::SHA1 #=> OpenSSL::Digest::SHA1
    irb(main):003:0> OpenSSL::PKCS5 #=> OpenSSL::PKCS5
2014-12-03 21:58:02 -08:00
Melissa Xie
3b43d1d822 Fix "nonexistent" typo in tests 2014-12-02 19:19:10 -05:00
Rafael Mendonça França
f69eabb0e6 Action View is needed for DebugExceptions
We should remove this dependency later.
2014-12-02 15:06:50 -02:00
Rafael Mendonça França
9fd6011f40 Merge pull request #17873 from kirs/refactor-debug-erb
Refactor debug view
2014-12-02 12:55:08 -02:00
Kir Shatrov
083f657c0f Refactor debug view
Avoid logic in ERB and use helpers
2014-12-02 09:45:20 -05:00
Rafael Mendonça França
921576b1d9 Merge pull request #17862 from lucasmazza/lm-hide-action
`_generate_paths_by_default` should always be private.
2014-12-02 11:40:11 -02:00
Aaron Patterson
c9a5ed22d5 Merge pull request #17827 from rkh/rkh-fix-or-pattern
Fix OR in Journey patterns
2014-12-01 07:55:29 -08:00
Kir Shatrov
9c15d23a77 Pretty-print request params on exception page 2014-12-01 01:03:09 -05:00
Sean Griffin
5493d16d9e Merge pull request #17823 from byroot/fix-mount-rack-apps-with-as
Pure rack apps can be mounted with a name
2014-11-29 15:31:12 -07:00
Jean Boussier
f413cbee8d Pure rack apps can be mounted with a name
See 9b15828b5c (commitcomment-8764492)
2014-11-29 09:24:43 -05:00
Erik Michaels-Ober
d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
claudiob
96d0f751f9 Bump required Ruby version to 2.1.0
[This article](http://weblog.rubyonrails.org/2014/8/20/Rails-4-2-beta1/#maintenance-consequences-and-rails-5-0) states that:

> Rails 5.0 is in most likelihood going to target Ruby 2.2.

Before the exact minimum version is fully decided, @arthurnn [suggests](https://github.com/rails/rails/pull/17830#issuecomment-64940383)
that **at least** version 2.1.0 **must** be required by the `gemspec` files.
2014-11-28 22:59:51 -08:00
Konstantin Haase
0d690d75fb make OR in journey patterns compile to a valid regular expression 2014-11-29 01:26:10 +01:00
Rafael Mendonça França
f25ad07f5a Start Rails 5 development 🎉
We will support only Ruby >= 2.1.

But right now we don't accept pull requests with syntax changes to drop
support to Ruby 1.9.
2014-11-28 15:00:06 -02:00
Santiago Pastorino
5ac824ecb7 Bump to rack 1.6.0.beta2 2014-11-27 16:54:44 -02:00
Abdelkader Boudih
2e4c9c2ee5 Merge pull request #17803 from sadfuzzy/patch-2
Update cookies.rb
Conflicts:
	actionpack/lib/action_dispatch/middleware/cookies.rb
2014-11-27 16:26:02 -02:00
rockrep
f7dbf388bd allow 'all' for :domain option in addition to :all 2014-11-26 13:34:52 -08:00
Matthew Draper
25b14b4d32 Merge pull request #17186 from tgxworld/header_authentication_token
Allow authentication header to not have to specify 'token=' key.
2014-11-27 01:44:13 +10:30
Bruno Sutic
9530c5786e
Refactor nested if 2014-11-26 13:28:59 +01:00
Artur Cygan
0a48d229de Remove extra empty line 2014-11-26 09:51:41 +01:00
Rafael Mendonça França
a882c69e7b ✂️ 2014-11-26 05:43:52 -02:00
dilpreet92
5a9acfdfa0 getting the location of the server 2014-11-26 05:42:24 -02:00
Rafael Mendonça França
d3c3a9161b Merge pull request #17728 from jcutrell/jcutrell/docs-to_session_value-for-pr
Adding simple docs for ActionDispatch::Flash::FlashHash#to_session_value
2014-11-25 22:16:51 -02:00
Rafael Mendonça França
f84ffdd5de Merge pull request #17733 from yuki24/do-not-rescue-exception-in-params-parser
Do not rescue Exception in ActionDispatch::ParamsParser
2014-11-25 20:01:58 -02:00
Rafael Mendonça França
e3f7817cec Use released rails-dom-testing 2014-11-25 19:43:36 -02:00
Bruno Sutic
3848bbe870
CSS fix for the router visualizer 2014-11-25 18:46:01 +01:00
Santiago Pastorino
c310be0e8b Merge pull request #17753 from gsamokovarov/dont-center-routing-table
Don't center the routes table on routing errors
2014-11-25 11:00:00 -02:00
Santiago Pastorino
d3dafaa0b3 Merge branch 'nil_script_name' 2014-11-25 10:31:26 -02:00
Santiago Pastorino
ad973ab8a0 Add regression test case to ensure script_name as nil is not used anymore in url_for 2014-11-25 10:29:48 -02:00
JONBRWN
1e5290a743 sets script_name to always be a string.
Closes #17615 #17616

when script_name is nil in the options hash, script_name is set to nil.

options = {script_name: nil}
script_name = options.delete(:script_name) {‘’} # => nil

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2014-11-25 10:27:34 -02:00
Sean Griffin
0bc04ced98 Changelog format 2014-11-24 19:18:33 -07:00
Sean Griffin
9545e6edc7 Merge branch 'deprecate-string-options-in-url-helpers' 2014-11-24 19:18:01 -07:00
Melanie Gilman
4d84922840 Deprecate string options in URL helpers
Fixes https://github.com/rails/rails/issues/16958

[Byron Bischoff & Melanie Gilman]
2014-11-24 21:16:33 -05:00
Xavier Noria
9685080a76 let mailer templates generate URLs by default [Xavier Noria, Richard Schneeman] 2014-11-24 14:33:50 -08:00
Genadi Samokovarov
12a468fe95 Don't center the routes table on routing errors 2014-11-24 22:57:56 +02:00
David Heinemeier Hansson
47728d53aa Merge pull request #17747 from gsamokovarov/missing-template-backtrace
Show source view and backtrace on missing template errors
2014-11-24 23:10:22 +03:00
Genadi Samokovarov
92ace39692 Show source view and backtrace on missing template errors
This will help you debug missing template errors, especially if they
come from a programmatic template selection. Thanks to @dhh for
suggesting that.

As a bonus, also show request and response info on the routing error
page for consistency.
2014-11-24 22:06:11 +02:00
Yuki Nishijima
1d85c707b6 Do not rescue Exception in ParamsParser
Unlike ShowExceptions or PublicExceptions, ParamsParser shouldn't
transform exceptions like Interrupt and NoMemoryError into ParserError.
2014-11-23 13:47:09 -08:00
Jonathan Cutrell
6dd0dc3e72 adding nodoc to private methods 2014-11-23 13:39:53 -05:00
Jonathan Cutrell
7fe3cf810f Adding simple docs for ActionDispatch::Flash::FlashHash#to_session_value 2014-11-23 13:03:01 -05:00
Godfrey Chan
23b21f6182 Don't show the warning if we're already raising the error anyway
If the route set is empty, or if none of the routes matches with a score > 0,
there is no point showing the deprecation message because we are already be
raising the `ActionController::UrlGenerationError` mentioned in the warning.

In this case it is the expected behavior and the user wouldn't have to take any
actions.
2014-11-23 01:46:51 -08:00
Godfrey Chan
8e73abbda8 Deprecate use_route in controller tests
Reference #17453
2014-11-23 01:42:46 -08:00
Godfrey Chan
c23bb156fe Deprecate passing an invalid name to Formatter#generate
The internal tests that (incorrectly) relied on this were already fixed in
938d130. However, we cannot simply fix this bug because the guides prior to
b7b9e92 recommended a workaround that relies on this buggy behavior.

Reference #17453
2014-11-23 01:40:32 -08:00
Godfrey Chan
938d130c62 Fix cases where the wrong name is passed to Formatter#generate
These are currently working "by accident" because `match_route` does not check
that the name is valid.
2014-11-23 01:08:53 -08:00
Godfrey Chan
77a276411e Test using ActionController::TestCase with engines
Reference #17453

[Godfrey Chan, Washington Luiz]
2014-11-23 00:07:30 -08:00
Godfrey Chan
ede97c6bb5 Merge pull request #17715 from tgxworld/fix_nil_anchor
Anchor should not be appended when set to nil/false.
2014-11-22 21:54:01 -08:00
yui-knk
9cb831ff84 [ci skip] Fix comment of ActionDispatch::Callbacks
cc ddce3dd
2014-11-23 13:22:36 +09:00
Guo Xiang Tan
46041c5208 Anchor should not be appended when set to nil/false.
Fixes https://github.com/rails/rails/issues/17714.
2014-11-23 08:23:26 +08:00
Godfrey Chan
b33ed44ad3 Remove outdated comments [ci skip]
They were introduced in 23b6def; the serial stuff has been removed since a5d80f8
2014-11-22 11:29:45 -08:00
claudiob
5aedabe82d Wrap code snippets in +, not backticks, in sdoc
I grepped the source code for code snippets wrapped in backticks in the comments
and replaced the backticks with plus signs so they are correctly displayed in
the Rails documentation.

[ci skip]
2014-11-20 15:45:15 -08:00
claudiob
02e821f329 Wrap code snippets in +, not backticks, in sdoc
[ci skip]
2014-11-20 14:46:27 -08:00
Ilya Katz
bc43d7f57d Use request method instead of ActionDispatch::Request#request_method instead of ActionDispatch::Request#method to pick up overrides by the middleware 2014-11-20 15:14:53 -05:00
Rafael Mendonça França
1b9e85dbbd Make sure assert_select can assert body tag
This reverts commit f93df52845766216f0fe36a4586f8abad505cac4, reversing
changes made to a455e3f4e9dbfb9630d47878e1239bc424fb7d13.

Conflicts:
	actionpack/lib/action_controller/test_case.rb
	actionview/lib/action_view/test_case.rb
2014-11-18 18:47:22 -02:00
Rafael Mendonça França
5b7b98d590 document_root_element need to be public 2014-11-17 16:37:17 -02:00
Rafael Mendonça França
5495771938 Merge pull request #17642 from tgxworld/fix_template_assertion_on_assigns
Fix for assigns(:..) resetting template assertions
2014-11-17 11:50:09 -02:00
Calvin Correli
c3e8d15e8b Fix for assigns(:..) resetting template assertions
When calling assigns(:...) or cookies(:...), template assertions would be reset, which they obviously shouldn't be.
2014-11-17 09:49:07 +08:00
Guillermo Iguaran
3a804aab95 Merge pull request #17630 from gsamokovarov/exception-wrapper-source-extract
Rename #source_extract to #source_extracts in ExceptionWrapper
2014-11-16 14:27:12 -05:00
Guillermo Iguaran
7830bb0d9d Merge pull request #17639 from gsamokovarov/faster-exception-wrapper-traces
Don't double check trace origin in ExceptionWrapper#traces
2014-11-16 14:26:28 -05:00
Genadi Samokovarov
ff1902789d Don't double check trace origin in ExceptionWrapper#traces
If a trace isn't an application one, then it comes from a framework.
That's the definition of framework trace. We can speed up the traces
generation if we don't double check that.
2014-11-16 20:20:14 +02:00
Genadi Samokovarov
2301d8cd26 Don't show full trace on routing errors
Since dbcbbcf2bc58e8971672b143d1c52c0244e33f26 the full trace is shown
by default on routing errors. While this is a nice feature to have, it
does take the attention off the routes table in this view and I think
this is what most of the people look for in this page.

Added an exception to the default trace switching rule to remove that
noise.
2014-11-16 19:19:48 +02:00
Genadi Samokovarov
20ad04e5fc Rename #source_extract to #source_extracts in ExceptionWrapper
It returns multiple source extracts since 1ed264bc. Also cleaned its
result structure, as we no longer need the file in a code extract.
2014-11-16 18:39:45 +02:00
Genadi Samokovarov
e05714fdbc Don't let #{application,framework,full}_trace be nil
Those three can be nil when exception backtrace is nil. This happens and
that forced a couple of nil guards in the code. I'm proposing to make
those always return an array, even on nil backtrace.
2014-11-16 17:17:06 +02:00
Santiago Pastorino
ee74d9c969 Merge pull request #17614 from gsamokovarov/exception-wrapper-basic-tests
Add basic tests for ActionDispatch::ExceptionWrapper
2014-11-14 12:21:22 -02:00
Genadi Samokovarov
5007929826 Add basic tests for ActionDispatch::ExceptionWrapper 2014-11-13 23:34:27 +01:00
Rafael Mendonça França
3c60fb429d Make FlashHash#key? work with symbol and string
Closes #17586
2014-11-11 01:04:06 -02:00
Rafael Mendonça França
091652cae8 Merge pull request #16535 from bf4/patch-1
Allow fallback to LegacyKeyGenerator when secret_key_base is not set but secrets.secret_token is
2014-11-10 20:38:46 -02:00
Godfrey Chan
6625000b73 Remove useless only_path: true in path helpers
We added a deprecation warning for these cases in aa1fadd, so these are now
causing deprecation warnings in the test output. AFAICT, in these two cases, the
option is not integral to the purpose of the test, so they can be safely removed
2014-11-10 00:47:25 -08:00
Godfrey Chan
aa6637d140 Pass the route name explicitly
Follow up to 212057b9. Since that commit, we need to pass the `route_name`
explicitly. This is one of the left-over cases that was not handled in that
commit, which was causing `use_route` to be ignored in functional tests.
2014-11-10 00:31:49 -08:00
Rafael Mendonça França
e16f8e58e7 Merge pull request #17523 from tgxworld/reset_session_after_calling_with_routing
Remove session to allow `with_routing` to be called twice.
2014-11-06 12:02:32 -02:00
Robert Evans
c12fbae932 Removed documentation that still mentioned using respond_with in place
of respond_to. respond_with was moved into the responders gem and deprecated
inside rails, so there is no need to mention it within rails itself.
2014-11-05 20:36:45 -08:00
Guo Xiang Tan
76f5a9afb3 Remove session to allow with_routing to be called twice.
Fixes: https://github.com/rails/rails/issues/16814
2014-11-05 23:38:02 +08:00
Rafael Mendonça França
8602fc5e11 Merge pull request #17480 from gsamokovarov/exception-wrapper-traces
Move DebugExceptions#traces_from_wrapper to ExceptionWrapper
2014-11-04 14:58:07 -02:00
Genadi Samokovarov
c7f2ee2213 Move DebugExceptions#traces_from_wrapper to ExceptionWrapper
ActionDispatch::ExceptionWrapper seems to be the more natural place for
this method to live in.
2014-11-03 19:12:04 +02:00
Benjamin Fleischer
db5f1a46f2 secret_token is now saved in Rails.application.secrets.secret_token
- `secrets.secret_token` is now used in all places `config.secret_token` was
  - `secrets.secret_token`, when not present in `config/secrets.yml`,
    now falls back to the value of `config.secret_token`
  - when `secrets.secret_token` is set, it over-writes
    `config.secret_token` so they are the same (for backwards-compatibility)
  - Update docs to reference app.secrets in all places
    - Remove references to `config.secret_token`, `config.secret_key_base`
- Warn that missing secret_key_base is deprecated
- Add tests for secret_token, key_generator, and message_verifier
  - the legacy key generator is used with the message verifier when
    secrets.secret_key_base is blank and secret_token is set
  - app.key_generator raises when neither secrets.secret_key_base nor
    secret_token are set
  - app.env_config    raises when neither secrets.secret_key_base nor
    secret_token are set
- Add changelog

Run focused tests via
ruby -w -Itest test/application/configuration_test.rb -n '/secret_|key_/'
2014-11-02 21:21:09 -06:00
Pablo Herrero
861b70e92f Call gsub with a Regexp instead of a String for better performance 2014-11-01 20:23:29 -03:00
Godfrey Chan
4daebedcc4 Prepare for 4.2.0.beta4 release 2014-10-30 14:12:24 -07:00
Xavier Noria
810b7914f3 Merge pull request #17440 from claudiob/remove-yet-another-redundant-to-s
Remove redundant `to_s` in interpolation
2014-10-30 19:47:36 +01:00
Aaron Patterson
c6f9518e24 Merge branch 'master-sec'
* master-sec:
  FileHandler should not be called for files outside the root
2014-10-30 11:39:46 -07:00
claudiob
64b09823e6 Remove redundant to_s in interpolation 2014-10-30 08:48:32 -07:00
Xavier Noria
e595d91ac2 edit pass over all warnings
This patch uniformizes warning messages. I used the most common style
already present in the code base:

* Capitalize the first word.

* End the message with a full stop.

* "Rails 5" instead of "Rails 5.0".

* Backticks for method names and inline code.

Also, converted a few long strings into the new heredoc convention.
2014-10-28 17:47:32 -07:00
Xavier Noria
b3bfa361c5 let's warn with heredocs
The current style for warning messages without newlines uses
concatenation of string literals with manual trailing spaces
where needed.

Heredocs have better readability, and with `squish` we can still
produce a single line.

This is a similar use case to the one that motivated defining
`strip_heredoc`, heredocs are super clean.
2014-10-28 16:35:24 -07:00
Godfrey Chan
777142d3a7 Typos in the deprecation message 2014-10-28 11:05:54 -07:00
Godfrey Chan
aa1fadd48f Deprecate the only_path option on *_path helpers.
In cases where this option is set to `true`, the option is redundant and can
be safely removed; otherwise, the corresponding `*_url` helper should be
used instead.

Fixes #17294.

See also #17363.

[Dan Olson, Godfrey Chan]
2014-10-28 09:43:33 -07:00
Andrew White
df0ea90cf1 Merge pull request #16229 from byroot/stop-swallowing-url-generation-errors
UrlGenerationError are not catched as 404 anymore
2014-10-27 22:46:19 +00:00
Jean Boussier
8e1362be3f UrlGenerationError are not catched as 404 anymore 2014-10-27 16:53:10 -04:00
Rafael Mendonça França
d27efbfbf5 Merge pull request #17362 from bronzle/fix_debug_exceptions_app
Show the user’s application in the source window and select the correct ...
2014-10-26 22:04:43 -05:00
Xavier Noria
8d7cf75684 give a better error message for misspelled helpers
See comment in this patch for the rationale.

References #16468
2014-10-25 14:06:33 +02:00
Guillermo Iguaran
0073d274de Use AS secure_compare for CSRF token comparison 2014-10-23 14:54:17 -03:00
Byron Bischoff
dbcbbcf2bc Show the user’s application in the source window and select the correct trace list, closes #17312 2014-10-23 09:53:43 -07:00
Accessd
20dcc0ab0a fix small typo in routing test 2014-10-21 19:46:29 +04:00
Rafael Mendonça França
42130e8572 Merge pull request #17313 from accessd/fix-url-generation-error-message
Fix url generation error message
2014-10-21 11:21:19 -02:00
Accessd
2224bf7992 fix url generation error message 2014-10-21 12:10:48 +04:00
Abdelkader Boudih
aefec3c61a remove duplicate method (_status_code) in action_dispatch 2014-10-19 17:59:07 +00:00
Prathamesh Sonpatki
295621e436 Make _status_code methods nodoc
- Also one minor change for documenting url_for method in ActionController::Metal.
[ci skip]
2014-10-19 22:12:59 +05:30
claudiob
6aa115e41f Replace (slower) block.call with (faster) yield
Performance optimization: `yield` with an implicit `block` is faster than `block.call`.
See http://youtu.be/fGFM_UrSp70?t=10m35s and the following benchmark:

```ruby
require 'benchmark/ips'

def fast
 yield
end

def slow(&block)
 block.call
end

Benchmark.ips do |x|
 x.report('fast') { fast{} }
 x.report('slow') { slow{} }
end

# => fast    154095 i/100ms
# => slow     71454 i/100ms
# =>
# => fast  7511067.8 (±5.0%) i/s -   37445085 in   4.999660s
# => slow  1227576.9 (±6.8%) i/s -    6145044 in   5.028356s
```
2014-10-17 11:46:37 -07:00
Rafael Mendonça França
be5521eb4e Use released rails-dom-testing 2014-10-16 16:53:46 -03:00
Yves Senn
400b0818fa some changelog formatting. [ci skip] 2014-10-16 09:11:41 +02:00