diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-02-26 17:18:29 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-02-26 17:18:45 -0800 |
commit | 050831803a9e553ba392a73732b00528dfa8c6ad (patch) | |
tree | 177a9050c5c07a80dedfc2bdc49b73b96d1a257d /actionpack/lib | |
parent | 6324eeefd7d1dd7b628afdcf436649062d12bbab (diff) | |
download | rails-050831803a9e553ba392a73732b00528dfa8c6ad.tar.gz rails-050831803a9e553ba392a73732b00528dfa8c6ad.tar.bz2 rails-050831803a9e553ba392a73732b00528dfa8c6ad.zip |
If IntegrationSession is initialized with an objects that responds to #routes, automatically extend the URL helpers from the RouteSet onto it
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 28 |
2 files changed, 21 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 47320883ac..6bc4303be3 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -203,7 +203,6 @@ module ActionDispatch url_for(options) end - protected :#{selector} END_EVAL helpers << selector end diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 88667d3570..0aff4250c1 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -162,12 +162,31 @@ module ActionDispatch # A running counter of the number of requests processed. attr_accessor :request_count + include ActionDispatch::Routing::UrlFor + # Create and initialize a new Session instance. def initialize(app) @app = app + + # If the app is a Rails app, make url_helpers available on the session + # This makes app.url_for and app.foo_path available in the console + if app.respond_to?(:routes) && app.routes.respond_to?(:url_helpers) + singleton_class.class_eval { include app.routes.url_helpers } + end + reset! end + def url_options + opts = super.reverse_merge( + :host => host, + :protocol => https? ? "https" : "http" + ) + + opts.merge!(:port => 443) if !opts.key?(:port) && https? + opts + end + # Resets the instance. This can be used to reset the state information # in an existing session instance, so it can be used from a clean-slate # condition. @@ -346,13 +365,8 @@ module ActionDispatch include ActionDispatch::Routing::UrlFor def url_options - opts = super.reverse_merge( - :host => host, - :protocol => https? ? "https" : "http" - ) - - opts.merge!(:port => 443) if !opts.key?(:port) && https? - opts + reset! unless @integration_session + @integration_session.url_options end # Delegate unhandled messages to the current session instance. |