Commit Graph

9904 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Yuutetu
5a10b417cd Fix typo in actionpack/lib/action_dispatch/routing/mapper.rb 2014-10-16 08:50:45 +09:00
Rafael Mendonça França
ba769cc483 Merge pull request #17255 from printercu/cors_exception_wrapper
ActionController::InvalidCrossOriginRequest fails with 422 instead of 500
2014-10-15 16:03:46 -03:00
Nicolas Cavigneaux
1c7dd65637 Use #tr instead of #gsub
`#tr` is more efficient than `#gsub` and can be used as a drop in
replacement in this context.
2014-10-14 22:32:23 +02:00
Max Melentiev
7a7ccc31e7 ActionController::InvalidCrossOriginRequest fails with 422 instead of 500
Fixes #15967
2014-10-14 18:56:51 +03:00
Nicolas Cavigneaux
3041bb2a94 Improve Journey compliance to RFC 3986
The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
2014-10-14 16:42:50 +02:00
Erik Michaels-Ober
2b6bacd192 Replace Array#shuffle.first with Array#sample 2014-10-13 11:54:04 +01:00
Aaron Patterson
d1123f2056 FileHandler should not be called for files outside the root
FileHandler#matches? should return false for files that are outside the
"root" path.
2014-10-10 16:00:03 -07:00
Guo Xiang Tan
3cc25864e3 Allow authentication header to not have to specify 'token=' key.
Fixes: https://github.com/rails/rails/issues/17108.
2014-10-10 09:38:03 +08:00
Stefan Henzen
e86cadc257 Request#check_method no longer breaks when :en is not available locale
Request#check_method would use to_sentence(locale: :en), which breaks when
I18n.available_locales does not include :en and
I18n.enforce_available_locales is true (default).

Inlined to_sentence functionality to solve this.
2014-10-09 15:45:49 +02:00
Neeraj Singh
590efa49cc Rephrasing sentences 2014-10-07 09:23:51 -04:00
Akira Matsuda
fe88af61f6 Responder was removed at ee77770d57de9da87b05a2fe84b9d46ec6852c62 2014-09-30 17:21:48 +09:00
Kasper Timm Hansen
f939904f23 Parse HTML as document fragment.
This is to match the changes in Rails Dom Testing rails/rails-dom-testing#20.
2014-09-29 21:41:52 +02:00
Erik Michaels-Ober
e2b49b203f Use Hash#each_key instead of Hash#keys.each
Hash#keys.each allocates an array of keys; Hash#each_key iterates through the
keys without allocating a new array. This is the reason why Hash#each_key
exists.
2014-09-29 17:27:10 +02:00
Vijay Dev
3a9b3ba082 Merge branch 'master' of github.com:rails/docrails 2014-09-28 06:11:30 +00:00
Rafael Mendonça França
4581d04477 Preparing for 4.2.0.beta2 release 2014-09-26 17:19:53 -03:00
Rafael Mendonça França
4af5899e25 Revert "Merge pull request #16966 from why-el/symbolize-path-params"
This reverts commit 9d05d6de52871e57bfbf54a60de005e8a5f5b0e4, reversing
changes made to 0863c9248fd47a15e88e05ce4fcd80966684c0e3.

The change in the behaviour reported at #16958 doesn't exist since 4.0
and 4.1 works in the same way
2014-09-25 18:07:22 -03:00
Mohamed Wael Khobalatte
f10b38bbc8 Ensure named path params are symbols (Fixes #16958) 2014-09-25 17:40:26 -03:00
Rafael Mendonça França
bc644c54d6 Keep the original implementation to not having to allocate new objects 2014-09-25 17:20:52 -03:00
Gert Goet
2d08fd2506 Remove internal options from query string of paths
Fixes #17057
2014-09-25 17:50:16 +02:00
Steven Harman
6c941ea405 Consistently markup etag options. 2014-09-16 15:24:24 -04:00
Steven Harman
2210521040 Consistently capitalize ETag. 2014-09-16 15:23:24 -04:00
Yuki Nishijima
75eaefcc2f Rescue Rack::Utils::ParameterTypeError instead of TypeError
As of rack/rack@167b648023, Rack raises
Rack::Utils::ParameterTypeError which inherits TypeError.

In terms of the behavior, Rescuing TypeError still works but this
method shouldn't rescue if TypeError is raised for other reasons.
2014-09-13 16:54:20 -07:00
suginoy
4f6f43338f [ci skip]Correct variables in the sample code 2014-09-10 22:20:26 +09:00
Prathamesh Sonpatki
29a10173e2 Remove extra 'has been' from deprecation warning about asserting selectors
[ci skip]
2014-09-09 11:08:18 +05:30
Prathamesh Sonpatki
ceb9ca2193 Remove extra 'has been' from the deprecation message
- [ci skip]
2014-09-09 10:47:40 +05:30
Javan Makhmali
66f8997671 Add support for Rack::ContentLength middelware 2014-09-06 12:33:29 -04:00
Jeremy Kemper
2a78d6f561 Deprecate implicit AD::Response splatting and Array conversion 2014-09-06 07:05:59 -07:00
Rafael Mendonça França
31bfcdc77c ✂️ 2014-09-05 16:47:57 -03:00
Rafael Mendonça França
2bb19fa739 Message doesn't need to be optional 2014-09-05 16:46:52 -03:00
Rafael Mendonça França
3f720d580f Merge pull request #14911 from estsauver/14908
Propagate test messages through assert_routing helper, Fixes #14908
2014-09-05 16:43:14 -03:00
Xavier Noria
4dfe140ef3 code gardening in ActionController::Renderers
* Renames _handle_render_options to _render_to_body_with_renderer, which is more
  intention-revealing.

* The name of the dynamically generated method for a renderer with key :js was
  "_render_option_js".

  That name is too weak. :js is an option if you see the render argument as just
  a generic options hash, but in the context of renderers that's the renderer
  key, is what identifies the renderer.

  Now "_render_with_renderer_js" is generated instead, which is crystal clear.

* The name of the dynamically generated method for the renderer was constructed
  using string literals in a few places. That is now encapsulated in a method.

* Since we were on it, also removed a couple of redundant selfs.
2014-09-04 00:45:01 +02:00
Sammy Larbi
2fae37f0ac Allow polymorphic routes with nil when a route can still be drawn
Suppose you have two resources routed in the following manner:

```ruby
resources :blogs do
  resources :posts
end

resources :posts
```

When using polymorphic resource routing like `url_for([@blog, @post])`, and `@blog` is `nil` Rails should still try to match the route to the top-level posts resource.

Fixes #16754
2014-08-31 11:39:46 -05:00
Robin Dupret
84c0f73c8d Refer to the library name instead of the constant
When we are loading a component and we want to know its version, we are
actually not speaking about the constant but the library itself.

[ci skip]

[Godfrey Chan & Xavier Noria]
2014-08-30 11:58:23 +02:00
David Heinemeier Hansson
7475b43cdb Merge branch 'master' of github.com:rails/rails 2014-08-29 14:54:08 -07:00
Peter Suschlik
a59a9b7f72 Don't rescue IPAddr::InvalidAddressError
IPAddr::InvalidAddressError does not exist in Ruby 1.9.3
and fails for JRuby in 1.9 mode.

As IPAddr::InvalidAddressError is a subclass of ArgumentError
(via IPAddr::Error) just rescuing ArgumentError is fine.
2014-08-29 09:05:31 +02:00
Aaron Patterson
6d86762fd8 Merge pull request #16637 from Agis-/redirect-with-constraint-route
Fix the router ignoring constraints when used together with a redirect route
2014-08-28 10:33:40 -07:00
schneems
0b1a87f73c Refactor out Dir.glob from ActionDispatch::Static
Dir.glob can be a security concern. The original use was to provide logic of fallback files. Example a request to `/` should render the file from `/public/index.html`. We can replace the dir glob with the specific logic it represents. The glob {,index,index.html} will look for the current path, then in the directory of the path with index file and then in the directory of the path with index.html. This PR replaces the glob logic by manually checking each potential match. Best case scenario this results in one less file API request, worst case, this has one more file API request.

Related to #16464

Update: added a test for when a file of a given name (`public/bar.html` and a directory `public/bar` both exist in the same root directory. Changed logic to accommodate this scenario.
2014-08-27 13:03:08 -05:00
Agis-
d78f3f0ec3 Don't ignore constraints in redirect routes
402c2af550
introduced a regression that caused any constraints added to redirect routes
to be ignored.

Fixes #16605
2014-08-25 00:18:25 +03:00
schneems
8e31fa3b72 Address comments on Gzip implementation
- don't mutate PATH_INFO in env, test
- test fallback content type matches Rack::File
- change assertion style
- make HTTP_ACCEPT_ENCODING comparison case insensitive
- return gzip path from method instead of true/false so we don't have to assume later
- don't allocate un-needed hash.

Original comments:

https://github.com/rails/rails/commit/
cfaaacd9763642e91761de54c90669a88d772e5a#commitcomment-7468728

cc @jeremy
2014-08-24 15:58:16 -05:00
Sam Aarons
f9a84bb236 Refactor ActionDispatch::RemoteIp
Refactored IP address checking in ActionDispatch::RemoteIp to rely on
the IPAddr class instead of the unwieldly regular expression to match
IP addresses. This commit keeps the same api but allows users to pass
IPAddr objects to config.action_dispatch.trusted_proxies in addition
to passing strings and regular expressions.

Example:

    # config/environments/production.rb
    config.action_dispatch.trusted_proxies = IPAddr.new('4.8.15.0/16')
2014-08-21 18:38:08 -07:00
Guo Xiang Tan
d3eb92d95a Avoid duplicating routes for HEAD requests.
Follow up to rails#15321

Instead of duplicating the routes, we will first match the HEAD request to
HEAD routes. If no match is found, we will then map the HEAD request to
GET routes.
2014-08-21 16:35:39 +08:00
schneems
cfaaacd976 Enable gzip compression by default
If someone is using ActionDispatch::Static to serve assets and makes it past the `match?` then the file exists on disk and it will be served. This PR adds in logic that checks to see if the file being served is already compressed (via gzip) and on disk, if it is it will be served as long as the client can handle gzip encoding. If not, then a non gzip file will be served.

This additional logic slows down an individual asset request but should speed up the consumer experience as compressed files are served and production applications should be delivered with a CDN. This PR allows a CDN to cache a gzip file by setting the `Vary` header appropriately. In net this should speed up a production application that are using Rails as an origin for a CDN. Non-asset request speed is not affected in this PR.
2014-08-20 22:33:06 -05:00
David Heinemeier Hansson
6a23bf0f4c Preparing for 4.2.0.beta1 release 2014-08-19 19:32:51 -07:00
Jeremy Kemper
79d50ce310 Merge pull request #16570 from bradleybuda/breach-mitigation-mask-csrf-token
CSRF token mask from breach-mitigation-rails gem
2014-08-19 18:17:07 -07:00
Bradley Buda
69fc0e1b5e Auth token mask from breach-mitigation-rails gem
This merges in the code from the breach-mitigation-rails gem that masks
authenticity tokens on each request by XORing them with a random set of
bytes. The masking is used to make it impossible for an attacker to
steal a CSRF token from an SSL session by using techniques like the
BREACH attack.

The patch is pretty simple - I've copied over the [relevant
code](https://github.com/meldium/breach-mitigation-rails/blob/master/lib/breach_mitigation/masking_secrets.rb)
and updated the tests to pass, mostly by adjusting stubs and mocks.
2014-08-19 15:28:07 -07:00
Rafael Mendonça França
d59a24d543 Protect against error when parsing parameters with Bad Request
Related with #11795.
2014-08-19 15:36:05 -03:00
Jeremy Kemper
4d1d81d338 Merge pull request #16299 from sikachu/ps-safer-ac-params
Update `ActionController::Parameters` to be more secure on parameters handling
2014-08-19 11:31:38 -07:00
Vijay Dev
41231ef6c6 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
	activerecord/lib/active_record/type/value.rb
2014-08-19 16:28:53 +00:00
Godfrey Chan
0d4d52a1cf Add missing require 2014-08-18 21:33:00 -07:00
Prem Sichanugrist
3fcbbc8a1c User #to_hash instead of calling super
Ruby 1.9.3 does not implement Hash#to_h, so we can't call `super` on it.
2014-08-18 23:42:42 -04:00
Prem Sichanugrist
3591dd59e0 Fix failing test on several methods on Parameter
* `each`
* `each_pair`
* `delete`
* `select!`
2014-08-18 20:42:46 -04:00
Prem Sichanugrist
9704379c78 Refactor code to reduce duplicate self.class.new 2014-08-18 20:42:45 -04:00
Prem Sichanugrist
bd7f47190e Add missing Hash methods to AC::Parameters
This is to make sure that `permitted` status is maintained on the
resulting object.

I found these methods that needs to be redefined by looking for
`self.class.new` in the code.

* extract!
* transform_keys
* transform_values
2014-08-18 20:42:45 -04:00
Prem Sichanugrist
5109740c6b Make AC::Params#to_h return Hash with safe keys
`ActionController::Parameters#to_h` now returns a `Hash` with
unpermitted keys removed. This change is to reflect on a security
concern where some method performed on an `ActionController::Parameters`
may yield a `Hash` object which does not maintain `permitted?` status.
If you would like to get a `Hash` with all the keys intact, duplicate
and mark it as permitted before calling `#to_h`.

    params = ActionController::Parameters.new(name: 'Senjougahara Hitagi')
    params.to_h # => {}

    unsafe_params = params.dup.permit!
    unsafe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

    safe_params = params.permit(:name)
    safe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

This change is consider a stopgap as we cannot chage the code to stop
`ActionController::Parameters` to inherit from
`HashWithIndifferentAccess` in the next minor release.

Also, adding a CHANGELOG entry to mention that
`ActionController::Parameters` will not inheriting from
`HashWithIndifferentAccess` in the next major version.
2014-08-18 20:42:45 -04:00
Rafael Mendonça França
9cb4d3e03b Deprecate TagAssertion instead of removing 2014-08-18 20:20:41 -03:00
Rafael Mendonça França
d2d809868c Merge pull request #15889 from carnesmedia/model-name
Use #model_name on instances instead of classes
2014-08-17 23:01:13 -03:00
Rafael Mendonça França
cdc00aba62 Merge branch 'loofah'
Conflicts:
	Gemfile
2014-08-17 22:51:13 -03:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
Lucas Mazza
9ee64f07f7 Deprecate NamedRouteCollection#helpers.
This method was removed at 210b338db20b1cdd0684f40bd78b52ed16148b99 but it is
used by third party gems to check if a named route was defined. To help on the
upgrade path on 4.2.0 we bring it back and emit a deprecation warning.
2014-08-17 22:36:22 -03:00
Godfrey Chan
e158ee50e6 Use AS::JSON for (de)serializing cookies
Use the Active Support JSON encoder for cookie jars using the `:json` or
`:hybrid` serializer. This allows you to serialize custom Ruby objects into
cookies by defining the `#as_json` hook on such objects.

Fixes #16520.
2014-08-17 12:41:42 -07:00
Godfrey Chan
a485633b16 responders 1.x won't do it. Told you to RTFM for details! 2014-08-17 12:19:23 -07:00
Godfrey Chan
b662273df3 The gem is called 'responders' 2014-08-17 11:58:17 -07:00
Godfrey Chan
24226c51f0 Raise a more helpful error for people who are using these extracted features 2014-08-17 11:54:09 -07:00
Godfrey Chan
beff925c32 Merge pull request #16467 from strzalek/cookies-digest-config-option2
Cookies digest config option (pt. 2)

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/lib/action_dispatch/middleware/cookies.rb
2014-08-17 11:23:14 -07:00
Godfrey Chan
14965baa09 Merge pull request #16484 from strzalek/remove-redundant-null-serializer
Remove redundant NullSerializer
2014-08-17 11:07:00 -07:00
José Valim
ee77770d57 Move respond_with to the responders gem
respond_with (and consequently the class-level respond_to)
are being removed from Rails. Instead of moving it to a 3rd
library, the functionality will be moved to responders gem
(at github.com/plataformatec/responders) which already provides
some responders extensions.
2014-08-17 13:20:22 -04:00
Jeremy Kemper
6c96602bc1 When your templates change, browser caches bust automatically.
New default: the template digest is automatically included in your ETags.
When you call `fresh_when @post`, the digest for `posts/show.html.erb`
is mixed in so future changes to the HTML will blow HTTP caches for you.
This makes it easy to HTTP-cache many more of your actions.

If you render a different template, you can now pass the `:template`
option to include its digest instead:

  fresh_when @post, template: 'widgets/show'

Pass `template: false` to skip the lookup. To turn this off entirely, set:

  config.action_controller.etag_with_template_digest = false
2014-08-17 06:52:17 -07:00
Aaron Patterson
6c51cc85da extract methods and metaprogram less. 2014-08-14 10:23:28 -07:00
Yves Senn
a1ddde15ae remove deprecated MissingHelperError proxy.
The error was moved outside of the `ClassMethods` module.
2014-08-14 09:37:21 +02:00
Yves Senn
9c91c168ab Merge pull request #16027 from tgxworld/template_assertions
Fixes to ActionController::TemplateAssertions
2014-08-14 08:38:35 +02:00
Aaron Patterson
43ce6e22b1 ask the scope object if it is a resource_method_scope 2014-08-13 19:47:26 -07:00
Aaron Patterson
e4cb3819df ask the scope for the action name 2014-08-13 19:44:05 -07:00
Aaron Patterson
374d66be3e reduce calls to scope_level
this will help us to encapsulate magical symbols so hopefully we can
eliminate hardcoded magic symbols
2014-08-13 19:40:57 -07:00
Aaron Patterson
047af8dd3c change to attr_reader 2014-08-13 19:30:47 -07:00
Aaron Patterson
677bc212eb scope_level is no longer a hash key, just use the ivar 2014-08-13 19:30:47 -07:00
Aaron Patterson
19bb6770c0 move the scope level key fully inside the scope object 2014-08-13 19:30:46 -07:00
Aaron Patterson
911ef972a5 move scope_level to a method on the scope object
now we don't have to have a hard coded key
2014-08-13 19:30:46 -07:00
Aaron Patterson
0127f02826 only look up scope level once
avoid hash lookups and remove depency on the instance
2014-08-13 19:13:58 -07:00
Aaron Patterson
91608dc342 only test prefix once
we don't need to repeat if statements
2014-08-13 18:47:16 -07:00
Aaron Patterson
318eea062e pass consistent parameters to canonical_action?
now we only have to look up @scope[:scope_level] once per call to
canonical_action? and we don't have a variable named "flag"
2014-08-13 18:42:26 -07:00
Aaron Patterson
3b908cba28 fewer operations on the options hash
since we pass `as` down, then we won't have to do an insert / delete
dance with the options hash
2014-08-13 18:34:21 -07:00
Aaron Patterson
d4981c393b this should be accessing the hash, not calling a method 2014-08-13 14:31:55 -07:00
Łukasz Strzałkowski
1a6ca03aec Remove redundant NullSerializer
Use one from ActiveSupport::MessageEncryptor module.
2014-08-13 23:09:19 +02:00
Guo Xiang Tan
b1ba333ea7 Fix assert_template for files.
The test was not failing for `assert_template file: nil` when a file
has been rendered.
2014-08-14 00:03:32 +08:00
Aditya Kapoor
2c8714568b [ci skip] correct default cache store class 2014-08-13 18:56:03 +05:30
Łukasz Strzałkowski
29be3f5d83 Add config option for cookies digest
You can now configure custom digest for cookies in the same way as `serializer`:

  config.action_dispatch.cookies_digest = 'SHA256'
2014-08-12 21:57:51 +02:00
Rafael Mendonça França
a2400308ea Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/integration_test.rb
	actionview/CHANGELOG.md
2014-08-12 11:10:42 -03:00
Akshay Vishnoi
51a759a745 use 'based on' instead of 'based off' [ci skip] 2014-08-12 18:40:14 +05:30
Santiago Pastorino
9c6c5aa929 Merge pull request #16440 from tgxworld/pass_log_in_block
Pass block for logging.
2014-08-09 10:42:45 -03:00
Guo Xiang Tan
bc53543cb3 Pass block for logging.
This follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-08-09 13:47:24 +08:00
Hendy Tanata
71c7fd1013 Uppercase HTML in docs.
[skip ci]
2014-08-08 14:27:05 -07:00
Santiago Pastorino
d70ba48c4d Revert "Merge pull request #16434 from strzalek/cookies-digest-config-option"
This reverts commit 705977620539e2be6548027042f33175ebdc2505, reversing
changes made to dde91e9bf5ab246f0f684b40288b272f4ba9a699.

IT BROKE THE BUILD!!!
2014-08-08 18:20:33 -03:00
Łukasz Strzałkowski
cfbedd3479 Add config option for cookies digest
You can now configure custom digest for cookies in the same way as `serializer`:

config.action_dispatch.cookies_digest = \SHA256'
2014-08-08 21:20:27 +02:00
Ryan Dao
1ed264bc60 Retrieve source code for the entire stack trace
Provide the ability to extract the source code of the entire exception stack
trace, not just the frame raising the error. This improves debugging
capability of the error page, especially for framework-related errors.
2014-08-08 15:04:55 +07:00
Guo Xiang Tan
14508aec70 Remove ActionController::RaiseActionExceptions.
The latest modification to the code was done in https://github.com/rails/rails/commit/5e3517ea. In Rails 3.2,
`ActionController#rescue_action` was deprecated and `rescue_action_without_handler` is no longer being used.
2014-08-07 17:43:36 +08:00
Aaron Patterson
2090615d39 refactor Redirecting so we do not need a controller instance 2014-08-06 14:17:57 -07:00
schneems
a9a6423fd6 [ci skip] Document ActionDispatch::Static 2014-08-05 12:17:03 -05:00
schneems
658b40e207 [ci skip] document ActionDispatch::FileHandler 2014-08-05 12:16:46 -05:00
schneems
e460e7cac0 [ci skip] Document PublicExceptions middleware 2014-08-05 11:45:44 -05:00
Aaron Patterson
3300fdedc7 avoid testing only_path
we know that this call only wants the path returned, so lets call a
method that returns the path.
2014-08-04 18:20:07 -07:00
Santiago Pastorino
930110b045 Regenerate sid when sbdy tries to fixate the session
Fixed broken test.

Thanks Stephen Richards for reporting.
2014-08-04 11:33:19 -03:00
Jack Danger Canty
0b8f35dd9c Using no_result_var in Journey's parser generator
Previously the generated parser had an intermediate local variable
`result` that really useful if you're building up a stateful object but
Journey always discards the result argument to the reduce functions.

This produces a simpler parser for anybody who actually wants to read
the thing.

Sadly, there's no real performance speedup with this change.
2014-08-03 15:23:56 -07:00
Vijay Dev
3bf2a4c0d2 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/testing.md
2014-08-02 12:09:07 +00:00
Vijay Dev
d9bd75a0d8 copy edits[ci skip] 2014-08-02 12:05:26 +00:00
Aaron Patterson
ea7fc2e7c0 just set the host, no need for another hash allocation / merge! 2014-08-01 11:55:47 -07:00
Aaron Patterson
8cbcd19d70 always return a string from find_script_name
this allows us to avoid nil checks on the return value
2014-08-01 11:45:59 -07:00
Aaron Patterson
e9bbe4a106 use get instead of accessing the named routes internals 2014-07-31 15:26:53 -07:00
Aaron Patterson
ed9b23d898 invert check so we fail faster
there's no reason to to_sym the string if it doesn't match the regexp
anyway
2014-07-31 11:25:01 -07:00
Aaron Patterson
3e9158bb95 do a hash lookup for collision detection
hash lookup should be faster than searching an array.
2014-07-31 11:22:05 -07:00
Carlos Antonio da Silva
ddb0d4bec1 Realign assignments ✂️ 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
0b859dfefe Do not reassign variable when mutation is happening
These methods mutate the path variable/argument so there is no need
to reassign it every time.
2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
091a59301f Only concatenate path if it was given rather than converting blindly 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
fafff357cc Rename variable to better show its intent 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
277247110c Simplify conditional 2014-07-31 13:24:16 -03:00
Carlos Antonio da Silva
8d61463f34 Push options check up so we can simplify internal methods 2014-07-31 13:24:16 -03:00
Carlos Antonio da Silva
dccdee7e2d Simplify code branch, remove #tap 2014-07-31 09:47:46 -03:00
Carlos Antonio da Silva
a9c0eb4392 Avoid a new hash object 2014-07-31 09:43:02 -03:00
Aaron Patterson
3429b0ccba remove useless deup
every call to default_resources_path_names allocates a new hash, no need
to dup
2014-07-30 18:11:24 -07:00
Aaron Patterson
20ec0d2aae push options inside the scope object 2014-07-30 17:20:37 -07:00
Aaron Patterson
dc3f25c8a5 turn scope in to a linked list
this makes scope rollback much easier
2014-07-30 17:19:00 -07:00
Aaron Patterson
68aea29cf5 remove alias_method_chain
we can `super` in to the previous implementation.
2014-07-30 14:53:28 -07:00
Aaron Patterson
09603275e9 avoid instrospection on the module
we already know what helpers are path helpers, so just iterate through
that list and define the helpers with warnings
2014-07-30 14:51:28 -07:00
Aaron Patterson
d9108abcad fix variable name 2014-07-30 14:46:45 -07:00
Aaron Patterson
210b338db2 split path_helpers and url_helpers
this lets us avoid hard coding a regexp for separating path and url
helpers in the clear! method.
2014-07-30 14:46:07 -07:00
Aaron Patterson
cf6658c284 add will remove the method if it exists already 2014-07-30 14:38:50 -07:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.

Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.

Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.

The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.

Paired @sgrif & @schneems
2014-07-30 12:01:45 -05:00
Santiago Pastorino
4efb36e7b4 Revert "Merge pull request #15305 from tgxworld/remove_unnecessary_require"
This reverts commit f632f79b8dcd144408c66a544984b2ba9cf52f87, reversing
changes made to 98c7fe87690ca4de6c46e8f69806e82e3f8af42d.

Closes #16343
2014-07-30 09:46:33 -03:00
Aaron Patterson
d7b726be00 oops! 💣
use helpers.include? so we don't get any false positives
2014-07-29 12:18:21 -07:00
Aaron Patterson
f889831ed6 ask the named routes collection if the route is defined
we should not be accessing internals to figure out if a method is
defined.
2014-07-29 12:15:04 -07:00
Aaron Patterson
0088b08dca helpers should be a Set so it doesn't grow unbounded
since helpers is a set, we can be confident about when to remove methods
from the module.
2014-07-29 11:48:14 -07:00
Aaron Patterson
41931b8af1 pass the module to define_named_route_methods
after this, we can disconnect @module from the instance
2014-07-29 11:32:17 -07:00
Aaron Patterson
a2e926698d only ask for the routes module once
we can cache the module on the stack, then reuse it
2014-07-29 11:28:45 -07:00
Aaron Patterson
d2d3376903 eval_block should be private 2014-07-29 11:07:43 -07:00