Permalink
Browse files

Merge pull request #3561 from bfolkens/3-1-stable-url_subdomain_with_…

…numeric_host

3 1 stable url subdomain with numeric host
  • Loading branch information...
2 parents 12df79c + 0fdcd54 commit dbecc5217071f4c1a9960e5aabe03798834070b6 @josevalim josevalim committed Nov 8, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/http/url.rb
  2. +11 −0 actionpack/test/controller/url_for_test.rb
@@ -64,7 +64,7 @@ def rewrite_authentication(options)
end
def host_or_subdomain_and_domain(options)
- return options[:host] unless options[:subdomain] || options[:domain]
+ return options[:host] unless (options[:subdomain] || options[:domain]) && named_host?(options[:host])
tld_length = options[:tld_length] || @@tld_length
@@ -16,6 +16,10 @@ def add_host!
W.default_url_options[:host] = 'www.basecamphq.com'
end
+ def add_numeric_host!
+ W.default_url_options[:host] = '127.0.0.1'
+ end
+
def test_exception_is_thrown_without_host
assert_raise ArgumentError do
W.new.url_for :controller => 'c', :action => 'a', :id => 'i'
@@ -67,6 +71,13 @@ def test_subdomain_may_be_changed
)
end
+ def test_subdomain_may_be_accepted_with_numeric_host
+ add_numeric_host!
+ assert_equal('http://127.0.0.1/c/a/i',
+ W.new.url_for(:subdomain => 'api', :controller => 'c', :action => 'a', :id => 'i')
+ )
+ end
+
def test_domain_may_be_changed
add_host!
assert_equal('http://www.37signals.com/c/a/i',

0 comments on commit dbecc52

Please sign in to comment.