diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-02-25 17:51:56 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-02-25 17:53:30 -0800 |
commit | 8760add31a0415b4635059cf7fadabc26946c0c2 (patch) | |
tree | f8f9466fad7ab23b9a3321c7d5adcad7f7421124 /actionpack/lib/action_dispatch/testing | |
parent | fc4582fb6684ce72f5628629ea7d061659b790f8 (diff) | |
download | rails-8760add31a0415b4635059cf7fadabc26946c0c2.tar.gz rails-8760add31a0415b4635059cf7fadabc26946c0c2.tar.bz2 rails-8760add31a0415b4635059cf7fadabc26946c0c2.zip |
Get URL helpers working again in integration tests.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 3bd9502e91..fb067601c8 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -219,17 +219,17 @@ module ActionDispatch @host = name end - # Returns the URL for the given options, according to the rules specified - # in the application's routes. - def url_for(options) - # ROUTES TODO: @app.router is not guaranteed to exist, so a generic Rack - # application will not work here. This means that a generic Rack application - # integration test cannot call url_for, since the application will not have - # #router on it. - controller ? - controller.url_for(options) : - generic_url_rewriter.rewrite(SharedTestRoutes, options) - end + # # Returns the URL for the given options, according to the rules specified + # # in the application's routes. + # def url_for(options) + # # ROUTES TODO: @app.router is not guaranteed to exist, so a generic Rack + # # application will not work here. This means that a generic Rack application + # # integration test cannot call url_for, since the application will not have + # # #router on it. + # controller ? + # controller.url_for(options) : + # generic_url_rewriter.rewrite(SharedTestRoutes, options) + # end private @@ -283,19 +283,6 @@ module ActionDispatch return response.status end - - # Get a temporary URL writer object - def generic_url_rewriter - env = { - 'REQUEST_METHOD' => "GET", - 'QUERY_STRING' => "", - "REQUEST_URI" => "/", - "HTTP_HOST" => host, - "SERVER_PORT" => https? ? "443" : "80", - "HTTPS" => https? ? "on" : "off" - } - ActionController::UrlRewriter.new(ActionDispatch::Request.new(env), {}) - end end module Runner @@ -367,6 +354,19 @@ module ActionDispatch end end + extend ActiveSupport::Concern + include ActionDispatch::Routing::UrlFor + + def merge_options(options) + opts = super.reverse_merge( + :host => host, + :protocol => https? ? "https" : "http" + ) + + opts.merge!(:port => 443) if !opts.key?(:port) && https? + opts + end + # Delegate unhandled messages to the current session instance. def method_missing(sym, *args, &block) reset! unless @integration_session |