]> git.openstreetmap.org Git - rails.git/blob - test/integration/short_link_test.rb
Call .to_sentence on site.key.table.entry. Translations are free to take advantage...
[rails.git] / test / integration / short_link_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class ShortLinkTest < 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('euu4oTas==')
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
17     # test without marker
18     get '/go/' + short_link
19     assert_redirected_to :controller => 'site', :action => 'index', :lat => lat, :lon => lon, :zoom => zoom
20
21     # test with marker
22     get '/go/' + short_link + "?m"
23     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat, :mlon => lon, :zoom => zoom
24
25     # test with layers and a marker
26     get '/go/' + short_link + "?m&layers=B000FTF"
27     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat, :mlon => lon, :zoom => zoom, :layers => "B000FTF"
28     get '/go/' + short_link + "?layers=B000FTF&m"
29     assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat, :mlon => lon, :zoom => zoom, :layers => "B000FTF"
30
31     # test with some random query parameters we haven't even implemented yet
32     get '/go/' + short_link + "?foobar=yes"
33     assert_redirected_to :controller => 'site', :action => 'index', :lat => lat, :lon => lon, :zoom => zoom, :foobar => "yes"
34   end
35 end