X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/550c4a3a45814fde5c809334c85f1ebc47659a82..86fae8980d97ba7fdd9345eb5e372fd4f8f20b7f:/test/controllers/site_controller_test.rb?ds=inline diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb index 6f6e7dcfa..5bd8df18d 100644 --- a/test/controllers/site_controller_test.rb +++ b/test/controllers/site_controller_test.rb @@ -1,20 +1,6 @@ require "test_helper" class SiteControllerTest < ActionDispatch::IntegrationTest - ## - # setup oauth keys - def setup - super - - Settings.id_key = create(:client_application).key - end - - ## - # clear oauth keys - def teardown - Settings.id_key = nil - end - ## # test all routes which lead to this controller def test_routes @@ -103,16 +89,16 @@ class SiteControllerTest < ActionDispatch::IntegrationTest # Test the index page redirects def test_index_redirect get root_path(:node => 123) - assert_redirected_to :controller => :browse, :action => :node, :id => 123 + assert_redirected_to node_path(123) get root_path(:way => 123) - assert_redirected_to :controller => :browse, :action => :way, :id => 123 + assert_redirected_to way_path(123) get root_path(:relation => 123) - assert_redirected_to :controller => :browse, :action => :relation, :id => 123 + assert_redirected_to relation_path(123) get root_path(:note => 123) - assert_redirected_to :controller => :browse, :action => :note, :id => 123 + assert_redirected_to :controller => :notes, :action => :show, :id => 123 get root_path(:query => "test") assert_redirected_to :controller => :geocoder, :action => :search, :query => "test" @@ -136,32 +122,25 @@ class SiteControllerTest < ActionDispatch::IntegrationTest # Test the permalink redirect def test_permalink get permalink_path(:code => "wBz3--") - assert_response :redirect assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125" get permalink_path(:code => "wBz3--", :m => "") - assert_response :redirect assert_redirected_to :controller => :site, :action => :index, :mlat => "4.8779296875", :mlon => "3.955078125", :anchor => "map=3/4.8779296875/3.955078125" get permalink_path(:code => "wBz3--", :layers => "T") - assert_response :redirect assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125&layers=T" get permalink_path(:code => "wBz3--", :node => 1) - assert_response :redirect - assert_redirected_to :controller => :browse, :action => :node, :id => 1, :anchor => "map=3/4.8779296875/3.955078125" + assert_redirected_to node_path(1, :anchor => "map=3/4.8779296875/3.955078125") get permalink_path(:code => "wBz3--", :way => 2) - assert_response :redirect - assert_redirected_to :controller => :browse, :action => :way, :id => 2, :anchor => "map=3/4.8779296875/3.955078125" + assert_redirected_to way_path(2, :anchor => "map=3/4.8779296875/3.955078125") get permalink_path(:code => "wBz3--", :relation => 3) - assert_response :redirect - assert_redirected_to :controller => :browse, :action => :relation, :id => 3, :anchor => "map=3/4.8779296875/3.955078125" + assert_redirected_to relation_path(3, :anchor => "map=3/4.8779296875/3.955078125") get permalink_path(:code => "wBz3--", :changeset => 4) - assert_response :redirect - assert_redirected_to :controller => :browse, :action => :changeset, :id => 4, :anchor => "map=3/4.8779296875/3.955078125" + assert_redirected_to changeset_path(4, :anchor => "map=3/4.8779296875/3.955078125") end # Test the key page @@ -177,7 +156,6 @@ class SiteControllerTest < ActionDispatch::IntegrationTest def test_edit get edit_path - assert_response :redirect assert_redirected_to login_path(:referer => "/edit") end @@ -451,7 +429,6 @@ class SiteControllerTest < ActionDispatch::IntegrationTest # Test the welcome page def test_welcome get welcome_path - assert_response :redirect assert_redirected_to login_path(:referer => "/welcome") session_for(create(:user)) @@ -490,6 +467,11 @@ class SiteControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "about" assert_select "div[lang='ar'][dir='rtl']" + + # Page should still render even with incorrect locale + get about_path(:about_locale => "zzz") + assert_response :success + assert_template "about" end # Test the export page @@ -509,7 +491,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest def test_offline get offline_path assert_response :success - assert_template "offline" + assert_select ".alert-warning" end # Test the rich text preview @@ -534,4 +516,11 @@ class SiteControllerTest < ActionDispatch::IntegrationTest assert_template "id" assert_template :layout => false end + + # Test the id frame when not logged in + def test_id_without_login + get id_path + + assert_redirected_to login_path(:referer => "/id") + end end