1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix trouble using :subdomain in development environment when using numeric addresses.

See-also pull request #3561 from 3-1-stable

    Otherwise the following occurs:

    TypeError: can't convert nil into String
        /Users/bfolkens/dev/bfolkens-rails-core/actionpack/lib/action_dispatch/http/url.rb:75:in host_or_subdomain_and_domain'
        /Users/bfolkens/dev/bfolkens-rails-core/actionpack/lib/action_dispatch/http/url.rb:37:in url_for'
        /Users/bfolkens/dev/bfolkens-rails-core/actionpack/lib/action_dispatch/routing/url_for.rb:147:in test_subdomain_may_be_accepted_with_numeric_host'
        /Users/bfolkens/dev/bfolkens-rails-core/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in run'
        /Users/bfolkens/dev/bfolkens-rails-core/activesupport/lib/active_support/callbacks.rb:426:in send'
        /Users/bfolkens/dev/bfolkens-rails-core/activesupport/lib/active_support/callbacks.rb:81:in run'
This commit is contained in:
Bradford Folkens 2011-11-08 07:52:35 -06:00
parent 1347665d89
commit bd559b0068
2 changed files with 12 additions and 1 deletions

View file

@ -64,7 +64,7 @@ module ActionDispatch
end
def host_or_subdomain_and_domain(options)
return options[:host] if options[:subdomain].nil? && options[:domain].nil?
return options[:host] if !named_host?(options[:host]) || (options[:subdomain].nil? && options[:domain].nil?)
tld_length = options[:tld_length] || @@tld_length

View file

@ -16,6 +16,10 @@ module AbstractController
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'
@ -81,6 +85,13 @@ module AbstractController
)
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',