Commit Graph

11814 Commits

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