X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c51786d10bc6dda488964f468a6a3071dd6912a8..c1b5ae0aa08be555588de8098b5ea8319f4c7925:/test/controllers/site_controller_test.rb diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb index 77b07db7d..eff9ce093 100644 --- a/test/controllers/site_controller_test.rb +++ b/test/controllers/site_controller_test.rb @@ -1,22 +1,6 @@ require "test_helper" class SiteControllerTest < ActionDispatch::IntegrationTest - ## - # setup oauth keys - def setup - super - - Settings.id_key = create(:client_application).key - Settings.potlatch2_key = create(:client_application).key - end - - ## - # clear oauth keys - def teardown - Settings.id_key = nil - Settings.potlatch2_key = nil - end - ## # test all routes which lead to this controller def test_routes @@ -114,7 +98,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest assert_redirected_to :controller => :browse, :action => :relation, :id => 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" @@ -163,7 +147,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest 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(:id => 4, :anchor => "map=3/4.8779296875/3.955078125") end # Test the key page @@ -180,7 +164,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest get edit_path assert_response :redirect - assert_redirected_to :controller => :users, :action => :login, :referer => "/edit" + assert_redirected_to login_path(:referer => "/edit") end # Test the error when trying to edit without public edits @@ -275,8 +259,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "edit" - assert_equal 1.0, assigns(:lat) - assert_equal 1.0, assigns(:lon) + assert_in_delta(1.0, assigns(:lat)) + assert_in_delta(1.0, assigns(:lon)) assert_equal 18, assigns(:zoom) end @@ -312,8 +296,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest get edit_path(:way => way.id) assert_response :success assert_template "edit" - assert_equal 3.0, assigns(:lat) - assert_equal 3.0, assigns(:lon) + assert_in_delta(3.0, assigns(:lat)) + assert_in_delta(3.0, assigns(:lon)) assert_equal 17, assigns(:zoom) end @@ -349,8 +333,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest get edit_path(:note => note.id) assert_response :success assert_template "edit" - assert_equal 1.0, assigns(:lat) - assert_equal 1.0, assigns(:lon) + assert_in_delta(1.0, assigns(:lat)) + assert_in_delta(1.0, assigns(:lon)) assert_equal 17, assigns(:zoom) end @@ -386,8 +370,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest get edit_path(:gpx => gpx.id) assert_response :success assert_template "edit" - assert_equal 1.0, assigns(:lat) - assert_equal 1.0, assigns(:lon) + assert_in_delta(1.0, assigns(:lat)) + assert_in_delta(1.0, assigns(:lon)) assert_equal 16, assigns(:zoom) end @@ -454,7 +438,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest def test_welcome get welcome_path assert_response :redirect - assert_redirected_to :controller => :users, :action => :login, :referer => "/welcome" + assert_redirected_to login_path(:referer => "/welcome") session_for(create(:user)) get welcome_path @@ -492,6 +476,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 @@ -511,7 +500,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 @@ -536,4 +525,12 @@ 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_response :redirect + assert_redirected_to login_path(:referer => "/id") + end end