| | 152 | def test_trailing_slash |
|---|
| | 153 | add_host! |
|---|
| | 154 | options = {:controller => 'foo', :trailing_slash => true, :action => 'bar', :id => '33'} |
|---|
| | 155 | assert_equal('http://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) |
|---|
| | 156 | end |
|---|
| | 157 | |
|---|
| | 158 | def test_trailing_slash_with_protocol |
|---|
| | 159 | add_host! |
|---|
| | 160 | options = { :trailing_slash => true,:protocol => 'https', :controller => 'foo', :action => 'bar', :id => '33'} |
|---|
| | 161 | assert_equal('https://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) ) |
|---|
| | 162 | assert_equal 'https://www.basecamphq.com/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string'})) |
|---|
| | 163 | end |
|---|
| | 164 | |
|---|
| | 165 | def test_trailing_slash_with_only_path |
|---|
| | 166 | options = {:controller => 'foo', :trailing_slash => true} |
|---|
| | 167 | assert_equal '/foo/', W.new.url_for(options.merge({:only_path => true})) |
|---|
| | 168 | options.update({:action => 'bar', :id => '33'}) |
|---|
| | 169 | assert_equal '/foo/bar/33/', W.new.url_for(options.merge({:only_path => true})) |
|---|
| | 170 | assert_equal '/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string',:only_path => true})) |
|---|
| | 171 | end |
|---|
| | 172 | |
|---|
| | 173 | def test_trailing_slash_with_anchor |
|---|
| | 174 | options = {:trailing_slash => true, :controller => 'foo', :action => 'bar', :id => '33', :only_path => true, :anchor=> 'chapter7'} |
|---|
| | 175 | assert_equal '/foo/bar/33/#chapter7', W.new.url_for(options) |
|---|
| | 176 | assert_equal '/foo/bar/33/?query=string#chapter7', W.new.url_for(options.merge({:query => 'string'})) |
|---|
| | 177 | end |
|---|
| | 178 | |
|---|
| | 179 | def test_trailing_slash_with_params |
|---|
| | 180 | url = W.new.url_for(:trailing_slash => true, :only_path => true, :controller => 'cont', :action => 'act', :p1 => 'cafe', :p2 => 'link') |
|---|
| | 181 | params = extract_params(url) |
|---|
| | 182 | assert_equal params[0], { :p1 => 'cafe' }.to_query |
|---|
| | 183 | assert_equal params[1], { :p2 => 'link' }.to_query |
|---|
| | 184 | end |
|---|
| | 185 | |
|---|