]> git.openstreetmap.org Git - rails.git/blob - test/integration/short_links_test.rb
Update Potlatch 2 to 2.3-596-gc119528 build
[rails.git] / test / integration / short_links_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class ShortLinksTest < ActionController::IntegrationTest
4   ##
5   # test the short link with various parameters and ensure they're
6   # kept in the redirect.
7   def test_short_link_params
8     assert_short_link_redirect('1N8H@P_5W')
9     assert_short_link_redirect(ShortLink::encode(-0.107846, 51.50771, 18))
10   end
11
12   ##
13   # utility method to test short links
14   def assert_short_link_redirect(short_link)
15     lon, lat, zoom = ShortLink::decode(short_link)
16     anchor = "#{zoom}/#{lat}/#{lon}"
17
18     # test without marker
19     get '/go/' + short_link
20     assert_redirected_to :controller => 'site', :action => 'index', :anchor => anchor
21
22     # test with marker
23     get '/go/' + short_link + "?m"
24     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :anchor => anchor
25
26     # test with layers and a marker
27     get '/go/' + short_link + "?m&layers=B000FTF"
28     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :layers => "B000FTF", :anchor => anchor
29     get '/go/' + short_link + "?layers=B000FTF&m"
30     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :layers => "B000FTF", :anchor => anchor
31
32     # test with some random query parameters we haven't even implemented yet
33     get '/go/' + short_link + "?foobar=yes"
34     assert_redirected_to :controller => 'site', :action => 'index', :foobar => "yes", :anchor => anchor
35   end
36 end