Changeset 7542
- Timestamp:
- 09/22/07 17:19:26 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_view/helpers/url_helper.rb (modified) (2 diffs)
- trunk/actionpack/test/template/url_helper_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r7541 r7542 1 1 *SVN* 2 3 * Fixed that setting the :host option in url_for would automatically turn off :only_path (since :host would otherwise not be shown) #9586 [Bounga] 2 4 3 5 * Added FormHelper#label #8641 [jcoglan] trunk/actionpack/lib/action_view/helpers/url_helper.rb
r7096 r7542 21 21 # ==== Options 22 22 # * <tt>:anchor</tt> -- specifies the anchor name to be appended to the path. 23 # * <tt>:only_path</tt> -- if true, returns the relative URL (omitting the protocol, host name, and port) (<tt>true</tt> by default )23 # * <tt>:only_path</tt> -- if true, returns the relative URL (omitting the protocol, host name, and port) (<tt>true</tt> by default unless <tt>:host</tt> is specified) 24 24 # * <tt>:trailing_slash</tt> -- if true, adds a trailing slash, as in "/archive/2005/". Note that this 25 25 # is currently not recommended since it breaks caching. … … 66 66 case options 67 67 when Hash 68 options = { :only_path => true }.update(options.symbolize_keys) 68 show_path = options[:host].nil? ? true : false 69 options = { :only_path => show_path }.update(options.symbolize_keys) 69 70 escape = options.key?(:escape) ? options.delete(:escape) : true 70 71 url = @controller.send(:url_for, options) trunk/actionpack/test/template/url_helper_test.rb
r7096 r7542 83 83 assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com") 84 84 end 85 86 def test_link_tag_without_host_option 87 ActionController::Base.class_eval { attr_accessor :url } 88 url = {:controller => 'weblog', :action => 'show'} 89 @controller = ActionController::Base.new 90 @controller.request = ActionController::TestRequest.new 91 @controller.url = ActionController::UrlRewriter.new(@controller.request, url) 92 assert_dom_equal(%q{<a href="/weblog/show">Test Link</a>}, link_to('Test Link', url)) 93 end 94 95 def test_link_tag_with_host_option 96 ActionController::Base.class_eval { attr_accessor :url } 97 url = {:controller => 'weblog', :action => 'show', :host => 'www.example.com'} 98 @controller = ActionController::Base.new 99 @controller.request = ActionController::TestRequest.new 100 @controller.url = ActionController::UrlRewriter.new(@controller.request, url) 101 assert_dom_equal(%q{<a href="http://www.example.com/weblog/show">Test Link</a>}, link_to('Test Link', url)) 102 end 85 103 86 104 def test_link_tag_with_query … … 176 194 assert_raises(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } 177 195 end 178 196 179 197 def test_link_to_unless 180 198 assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog")