diff options
author | José Valim <jose.valim@gmail.com> | 2010-12-03 12:27:50 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-12-03 12:27:50 +0100 |
commit | 78afe68afbfec229db50148c00e48417cd2a352f (patch) | |
tree | 9bb64de1b9bbad9a1f51a02cf5175675582c0310 /actionpack/test/dispatch/request_test.rb | |
parent | 9a3e29e126d9daf6175b4d2be50112d1c8771d17 (diff) | |
parent | 1e26bda0959c313ce5c1816bf4958b542050e5e2 (diff) | |
download | rails-78afe68afbfec229db50148c00e48417cd2a352f.tar.gz rails-78afe68afbfec229db50148c00e48417cd2a352f.tar.bz2 rails-78afe68afbfec229db50148c00e48417cd2a352f.zip |
Merge remote branch 'joshk/redirect_routing'
Conflicts:
actionpack/CHANGELOG
actionpack/lib/action_controller/metal/mime_responds.rb
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/dispatch/request_test.rb')
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 8f672c1149..75b674ec1a 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -1,6 +1,31 @@ require 'abstract_unit' class RequestTest < ActiveSupport::TestCase + + def url_for(options = {}) + options.reverse_merge!(:host => 'www.example.com') + ActionDispatch::Http::URL.url_for(options) + end + + test "url_for class method" do + e = assert_raise(ArgumentError) { url_for(:host => nil) } + assert_match(/Please provide the :host parameter/, e.message) + + assert_equal '/books', url_for(:only_path => true, :path => '/books') + + assert_equal 'http://www.example.com', url_for + assert_equal 'http://api.example.com', url_for(:subdomain => 'api') + assert_equal 'http://www.ror.com', url_for(:domain => 'ror.com') + assert_equal 'http://api.ror.co.uk', url_for(:host => 'www.ror.co.uk', :subdomain => 'api', :tld_length => 2) + assert_equal 'http://www.example.com:8080', url_for(:port => 8080) + assert_equal 'https://www.example.com', url_for(:protocol => 'https') + assert_equal 'http://www.example.com/docs', url_for(:path => '/docs') + assert_equal 'http://www.example.com#signup', url_for(:anchor => 'signup') + assert_equal 'http://www.example.com/', url_for(:trailing_slash => true) + assert_equal 'http://dhh:supersecret@www.example.com', url_for(:user => 'dhh', :password => 'supersecret') + assert_equal 'http://www.example.com?search=books', url_for(:params => { :search => 'books' }) + end + test "remote ip" do request = stub_request 'REMOTE_ADDR' => '1.2.3.4' assert_equal '1.2.3.4', request.remote_ip |