Commit Graph

105 Commits

Author SHA1 Message Date
José Valim
5c565a2942 Merge pull request #6588 from nbibler/polymorphic_to_model
Correct the use of to_model in polymorphic routing
2012-06-01 16:42:09 +02:00
brainopia
4121938626 Support cookie jar options for all cookie stores 2012-04-30 04:14:51 +04:00
Sergey Nartimov
67e8004ffd remove calls to deprecated find(:first) in actionpack test suite 2012-04-26 21:50:35 +03:00
Jose and Yehuda
56cdc81c08 Remove default match without specified method
In the current router DSL, using the +match+ DSL
method will match all verbs for the path to the
specified endpoint.

In the vast majority of cases, people are
currently using +match+ when they actually mean
+get+. This introduces security implications.

This commit disallows calling +match+ without
an HTTP verb constraint by default. To explicitly
match all verbs, this commit also adds a
:via => :all option to +match+.

Closes #5964
2012-04-24 22:52:26 -05:00
Grant Hutchins
18d275ada1 Make controller namespace partial prefix optional
config.action_view.prefix_partial_path_with_controller_namespace

This allows you to choose to render @post using
/posts/_post.erb instead of /admin/posts/_post.erb
inside Admin::PostsController.
2012-03-28 20:21:46 -04:00
Grant Hutchins
a0e83d5af7 Test that render gets correct exact template name 2012-03-28 19:42:20 -04:00
Carlos Antonio da Silva
71566c3573 Remove rescue_action from compatibility module and tests 2012-01-17 10:04:37 -02:00
Jon Leighton
0b72a04d0c Deprecate set_table_name in favour of self.table_name= or defining your own method. 2011-11-29 20:13:36 +00:00
José Valim
fd86a1b6b0 Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
Joseph Wong
66dee26930 Fixed session ID fixation for ActiveRecord::SessionStore
I have found that Rails will take an invalid session ID specified by the
client and materialize a session based on that session ID. This means
that it is possible, among other things, for a client to use an
arbitrarily weak session ID or for a client to resurrect a previous used
session ID. In other words, we cannot guarantee that all session IDs are
generated by the server and that they are (statistically) unique through
time.

The fix is to always generate a new session ID in #get_session if an
existing session cannot be found under the incoming session ID.

Also added new tests that make sure that an invalid session ID is never
materialized into a new session, regardless of whether it comes in via a
cookie or a URL parameter (when :cookie_only => false).
2011-07-12 11:09:11 -07:00
Damien Mathieu
ac15bcebf2 provide a more explicit message when using url_for with nil
This fixes the problem of having a non-explicit message when the :location option is not provided in respond_with.
2011-07-02 18:53:54 +02:00
Frederick Cheung
8a722e0912 Take into account time spent in AR even if a redirect occurs or if it is after the render 2011-05-23 10:58:43 +01:00
Tom Ward
6d96124284 Reset ActiveRecord::LogSubscriber runtime at the start of each request
Previously the runtime was reset implicitly when #cleanup_view_runtime was called at the end of most requests. However, this doesn't happen when the request redirects, or send_file is called.  Consequently, the ActiveRecord runtime recorded in the logs included the time taken for both the current request and the previous redirect.  Explicitly resetting at the start of each request ensures that this can't happen, no matter what occurs previously.
2011-05-14 10:39:01 +01:00
Tom Ward
518ffcd168 Escape regex in controller_runtime_test to actually check that the ActiveRecord message appears 2011-05-14 10:39:01 +01:00
Vishnu Atrai
33f0b6b67d minor cleaning 2011-05-10 22:51:54 +05:30
Pavel Gorbokon
96bae30538 Replace rudimentary named_scope with scope. [#6052 state:resolved]
* rename method names (actually in tests)
* rename instance variable @_named_scopes_cache to @_scopes_cache
* rename references in doc comments
* don't touch CHANGELOG :)
2010-12-15 14:02:30 -08:00
José Valim
d5779efaf2 Ensure calling reset session twice does not raise errors. 2010-11-20 21:56:08 +01:00
José Valim
9c9f416d39 Allow AR Session Store to be renewed 2010-11-11 14:17:14 +01:00
Xavier Noria
21ff8849bb in regexps, the dot in a character class is not a metacharacter 2010-10-15 16:31:00 +02:00
Emilio Tagua
c8db1adc0d Remove duplicated class test. copy/paste fail? 2010-09-28 16:40:28 -03:00
Emilio Tagua
2d274a5208 Use parentheses when using assert_match followed by a regexp to avoid warnings. 2010-09-27 11:19:19 -03:00
Carlos Antonio da Silva
7fc1edd790 Remove deprecated stuff in ActionController
This removes all deprecated classes in ActionController related to
Routing, Abstract Request/Response and Integration/IntegrationTest.
All tests and docs were changed to ActionDispatch instead of ActionController.
2010-09-26 02:13:45 +08:00
Piotr Sarnacki
b3eb26a161 Removed deprecated RouteSet API, still many tests fail 2010-09-05 13:44:36 +02:00
Piotr Sarnacki
2607def862 Use new ActiveModel::Naming.route_key in polymorphic_routes 2010-09-03 22:59:15 +02:00
Piotr Sarnacki
613cbe1f00 Add possibility to explicitly call engine's routes through polymorphic_routes, for example: polymorphic_url([blog, @post]) 2010-09-03 22:59:13 +02:00
Piotr Sarnacki
8ec2175aee Added more tests for polymorphic_url with namespaced models and implemented missing use cases 2010-09-03 22:59:13 +02:00
José Valim
6d04fa6dc4 Deprecate the old router DSL. Since it is still used intensively across ActionPack test suite, patches that translates Rails internal tests to the new router DSL are welcome (note though that a few tests shouldn't be translated since they are testing exactly the old mapper API, like the ones in actionpack/test/controller/resource_test.rb and actionpack/test/controller/routing_test.rb) 2010-06-28 12:23:41 +02:00
Prem Sichanugrist
617e94658d Make sure that Rails doesn't resent session_id cookie over and over again if it's already there [#2485 state:resolved]
This apply to only Active Record store and Memcached store, as they both store only the session_id, which will be unchanged, in the cookie.

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-25 09:41:52 +02:00
José Valim
6788db824a Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing frameworks like ActiveRecord and ActiveResource to log outsude Rails::Application [#4816 state:resolved] 2010-06-24 13:23:43 +02:00
Michael Lovitt
49f52c3d91 Sessions should not be created until written to and session data should be destroyed on reset.
[#4938]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-23 11:56:35 -07:00
Andrew White
ed3f042e99 Make polymorphic_url and scaffolding work with uncountable resources [#3930 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-20 00:15:41 +02:00
José Valim
c536835957 Cut the fat and make session stores rely on request.cookie_jar and change set_session semantics to return the cookie value instead of a boolean. 2010-05-18 03:18:23 +02:00
Joshua Peek
cdf8c35ffd Consistent routing language 2010-03-30 14:05:42 -05:00
Carlhuda
d78e3fe73f Fix failing Action Pack tests 2010-03-02 14:41:12 -08:00
Carlhuda
5797575bac Stop setting UrlFor using SharedTestHelpers 2010-02-26 15:40:36 -08:00
Carlhuda
98f77e0827 Rename named_url_helpers to url_helpers and url_helpers to url_for 2010-02-26 15:04:50 -08:00
Carlhuda
a278f23310 Fix all of AP's tests with the non global router 2010-02-25 17:53:01 -08:00
Carlhuda
24ab5665b2 Revert "Fix test load paths for those not using bundler"
This reverts commit eec2d301d4ce9df9c71c1a5aa63053eb970b6818.

This commit broke tests. You cannot have a file called "bundler" on the load path.
2010-02-23 17:31:17 -08:00
Martin Schürrer
6bc24d40d5 Use ActionDispatch::Routing everywhere 2010-02-21 13:43:51 -08:00
José Valim
3f948a0e29 Merge master. 2010-02-17 00:48:04 +01:00
Prem Sichanugrist
f0523f72b4 Rename Rails::Subscriber to Rails::LogSubscriber 2010-02-16 22:36:15 +01:00
Joshua Peek
eec2d301d4 Fix test load paths for those not using bundler 2010-02-15 10:20:11 -06:00
José Valim
378464a2e4 Default to sync instrumentation. 2010-01-21 13:09:12 +01:00
José Valim
a8e25a518a Move parameters to the top on logging. 2010-01-19 15:35:24 +01:00
José Valim
27d9836ad3 Add ActionDispatch::Railties::Subscriber and finish tidying up the logging. 2010-01-17 12:43:17 +01:00
José Valim
f921ad5c97 Tidy up ActiveRecord and Views runtime information on process action logger. 2010-01-14 01:07:03 +01:00
José Valim
01839834fd ControllerRuntime tests also use Rails::Subscriber::TestHelper. 2010-01-13 01:19:24 +01:00
José Valim
f149eb19d4 From now on, parameters defined in default_url_options can be absent from named routes.
This allows the following setup to work:

  # app/controllers/application_controller.rb
  class ApplicationController
    def default_url_options(options=nil)
      { :locale => I18n.locale }
    end
  end

  # From your views and controllers:
  I18n.locale                 #=> :en
  users_url                   #=> "/en/users"
  users_url(:pl)              #=> "/pl/users"
  user_url(1)                 #=> "/en/users/1"
  user_url(:pl, 1)            #=> "/pl/users/1"
  user_url(1, :locale => :pl) #=> "/pl/users/1"

If you provide all expected parameters, it still works as previously.
But if any parameter is missing, it tries to assign all possible ones
with the hash returned in default_url_options or the one passed straight
to the named route method.

Beware that default_url_options in ApplicationController is not shared
with ActionMailer, so you are required to always give the locale in your
email views.
2010-01-07 15:34:14 +01:00
José Valim
f2d276fefd Ensure no notification is on the queue before running notifications related tests. 2010-01-03 23:39:09 +01:00
José Valim
6fbe9ef2ff Use namespaces in notifications. 2010-01-03 20:39:42 +01:00