mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix url_for options[:subdomain] to allow objects as values
* e.g. blog_url(subdomain: current_user) instead of blog_url(subdomain: current_user.to_param)
This commit is contained in:
parent
a5589db063
commit
5f67cfeda1
2 changed files with 9 additions and 1 deletions
|
@ -70,7 +70,7 @@ module ActionDispatch
|
|||
|
||||
host = ""
|
||||
unless options[:subdomain] == false
|
||||
host << (options[:subdomain] || extract_subdomain(options[:host], tld_length))
|
||||
host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)).to_param
|
||||
host << "."
|
||||
end
|
||||
host << (options[:domain] || extract_domain(options[:host], tld_length))
|
||||
|
|
|
@ -71,6 +71,14 @@ module AbstractController
|
|||
)
|
||||
end
|
||||
|
||||
def test_subdomain_may_be_object
|
||||
model = mock(:to_param => 'api')
|
||||
add_host!
|
||||
assert_equal('http://api.basecamphq.com/c/a/i',
|
||||
W.new.url_for(:subdomain => model, :controller => 'c', :action => 'a', :id => 'i')
|
||||
)
|
||||
end
|
||||
|
||||
def test_subdomain_may_be_removed
|
||||
add_host!
|
||||
assert_equal('http://basecamphq.com/c/a/i',
|
||||
|
|
Loading…
Reference in a new issue