From 90e46a58de583ac2bd7bb43077faa94186957a7a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 9 Mar 2012 18:28:06 +0000 Subject: [PATCH 1/1] Add routing tests for all supported routes --- test/functional/amf_controller_test.rb | 13 ++ test/functional/api_controller_test.rb | 25 +++ test/functional/browse_controller_test.rb | 37 ++++ test/functional/changeset_controller_test.rb | 73 ++++++++ .../functional/diary_entry_controller_test.rb | 80 ++++++++ test/functional/export_controller_test.rb | 15 +- test/functional/geocoder_controller_test.rb | 54 +++++- test/functional/message_controller_test.rb | 39 +++- test/functional/node_controller_test.rb | 25 +++ .../oauth_clients_controller_test.rb | 36 ++++ test/functional/oauth_controller_test.rb | 32 ++++ test/functional/old_node_controller_test.rb | 13 ++ .../old_relation_controller_test.rb | 13 ++ test/functional/old_way_controller_test.rb | 13 ++ test/functional/relation_controller_test.rb | 42 +++++ test/functional/search_controller_test.rb | 22 ++- test/functional/site_controller_test.rb | 49 +++++ test/functional/swf_controller_test.rb | 10 +- test/functional/trace_controller_test.rb | 142 +++++++++++++++ .../functional/user_blocks_controller_test.rb | 58 ++++++ test/functional/user_controller_test.rb | 172 ++++++++++++++++++ .../user_preference_controller_test.rb | 28 ++- test/functional/user_roles_controller_test.rb | 24 +++ test/functional/way_controller_test.rb | 29 +++ 24 files changed, 1028 insertions(+), 16 deletions(-) create mode 100644 test/functional/oauth_clients_controller_test.rb create mode 100644 test/functional/oauth_controller_test.rb create mode 100644 test/functional/user_blocks_controller_test.rb create mode 100644 test/functional/user_roles_controller_test.rb diff --git a/test/functional/amf_controller_test.rb b/test/functional/amf_controller_test.rb index 8bef10bd1..46ff71eb7 100644 --- a/test/functional/amf_controller_test.rb +++ b/test/functional/amf_controller_test.rb @@ -5,6 +5,19 @@ include Potlatch class AmfControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/amf/read", :method => :post }, + { :controller => "amf", :action => "amf_read" } + ) + assert_routing( + { :path => "/api/0.6/amf/write", :method => :post }, + { :controller => "amf", :action => "amf_write" } + ) + end + def test_getway # check a visible way id = current_ways(:visible_way).id diff --git a/test/functional/api_controller_test.rb b/test/functional/api_controller_test.rb index 9226e3892..adc433fe0 100644 --- a/test/functional/api_controller_test.rb +++ b/test/functional/api_controller_test.rb @@ -18,6 +18,31 @@ class ApiControllerTest < ActionController::TestCase # reall reject it, however this is to test to see if the api changes. end + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/capabilities", :method => :get }, + { :controller => "api", :action => "capabilities" } + ) + assert_recognizes( + { :controller => "api", :action => "capabilities" }, + { :path => "/api/0.6/capabilities", :method => :get } + ) + assert_routing( + { :path => "/api/0.6/map", :method => :get }, + { :controller => "api", :action => "map" } + ) + assert_routing( + { :path => "/api/0.6/trackpoints", :method => :get }, + { :controller => "api", :action => "trackpoints" } + ) + assert_routing( + { :path => "/api/0.6/changes", :method => :get }, + { :controller => "api", :action => "changes" } + ) + end + # ------------------------------------- # Test reading a bounding box. # ------------------------------------- diff --git a/test/functional/browse_controller_test.rb b/test/functional/browse_controller_test.rb index f4da4c1a8..04b690ebf 100644 --- a/test/functional/browse_controller_test.rb +++ b/test/functional/browse_controller_test.rb @@ -4,6 +4,43 @@ require 'browse_controller' class BrowseControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/browse/start", :method => :get }, + { :controller => "browse", :action => "start" } + ) + assert_routing( + { :path => "/browse/node/1", :method => :get }, + { :controller => "browse", :action => "node", :id => "1" } + ) + assert_routing( + { :path => "/browse/node/1/history", :method => :get }, + { :controller => "browse", :action => "node_history", :id => "1" } + ) + assert_routing( + { :path => "/browse/way/1", :method => :get }, + { :controller => "browse", :action => "way", :id => "1" } + ) + assert_routing( + { :path => "/browse/way/1/history", :method => :get }, + { :controller => "browse", :action => "way_history", :id => "1" } + ) + assert_routing( + { :path => "/browse/relation/1", :method => :get }, + { :controller => "browse", :action => "relation", :id => "1" } + ) + assert_routing( + { :path => "/browse/relation/1/history", :method => :get }, + { :controller => "browse", :action => "relation_history", :id => "1" } + ) + assert_routing( + { :path => "/browse/changeset/1", :method => :get }, + { :controller => "browse", :action => "changeset", :id => "1" } + ) + end + def test_start xhr :get, :start assert_response :success diff --git a/test/functional/changeset_controller_test.rb b/test/functional/changeset_controller_test.rb index ef8043340..a586b3dee 100644 --- a/test/functional/changeset_controller_test.rb +++ b/test/functional/changeset_controller_test.rb @@ -4,6 +4,79 @@ require 'changeset_controller' class ChangesetControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/changeset/create", :method => :put }, + { :controller => "changeset", :action => "create" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1/upload", :method => :post }, + { :controller => "changeset", :action => "upload", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1/download", :method => :get }, + { :controller => "changeset", :action => "download", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1/expand_bbox", :method => :post }, + { :controller => "changeset", :action => "expand_bbox", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1", :method => :get }, + { :controller => "changeset", :action => "read", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1", :method => :put }, + { :controller => "changeset", :action => "update", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changeset/1/close", :method => :put }, + { :controller => "changeset", :action => "close", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/changesets", :method => :get }, + { :controller => "changeset", :action => "query" } + ) + assert_routing( + { :path => "/user/name/edits", :method => :get }, + { :controller => "changeset", :action => "list", :display_name => "name" } + ) + assert_routing( + { :path => "/user/name/edits/feed", :method => :get }, + { :controller => "changeset", :action => "feed", :display_name => "name", :format => :atom } + ) + assert_routing( + { :path => "/browse/friends", :method => :get }, + { :controller => "changeset", :action => "list", :friends => true } + ) + assert_routing( + { :path => "/browse/nearby", :method => :get }, + { :controller => "changeset", :action => "list", :nearby => true } + ) + assert_routing( + { :path => "/browse/changesets", :method => :get }, + { :controller => "changeset", :action => "list" } + ) + assert_routing( + { :path => "/browse/changesets/feed", :method => :get }, + { :controller => "changeset", :action => "feed", :format => :atom } + ) + assert_recognizes( + { :controller => "changeset", :action => "list" }, + { :path => "/browse", :method => :get } + ) + assert_recognizes( + { :controller => "changeset", :action => "list" }, + { :path => "/history", :method => :get } + ) + assert_recognizes( + { :controller => "changeset", :action => "feed", :format => :atom }, + { :path => "/history/feed", :method => :get } + ) + end + # ----------------------- # Test simple changeset creation # ----------------------- diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index 738fbe671..54b4cdf7e 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -5,6 +5,86 @@ class DiaryEntryControllerTest < ActionController::TestCase include ActionView::Helpers::NumberHelper + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/diary", :method => :get }, + { :controller => "diary_entry", :action => "list" } + ) + assert_routing( + { :path => "/diary/language", :method => :get }, + { :controller => "diary_entry", :action => "list", :language => "language" } + ) + assert_routing( + { :path => "/user/username/diary", :method => :get }, + { :controller => "diary_entry", :action => "list", :display_name => "username" } + ) + assert_routing( + { :path => "/diary/friends", :method => :get }, + { :controller => "diary_entry", :action => "list", :friends => true } + ) + assert_routing( + { :path => "/diary/nearby", :method => :get }, + { :controller => "diary_entry", :action => "list", :nearby => true } + ) + + assert_routing( + { :path => "/diary/rss", :method => :get }, + { :controller => "diary_entry", :action => "rss", :format => :rss } + ) + assert_routing( + { :path => "/diary/language/rss", :method => :get }, + { :controller => "diary_entry", :action => "rss", :language => "language", :format => :rss } + ) + assert_routing( + { :path => "/user/username/diary/rss", :method => :get }, + { :controller => "diary_entry", :action => "rss", :display_name => "username", :format => :rss } + ) + + assert_routing( + { :path => "/user/username/diary/comments", :method => :get }, + { :controller => "diary_entry", :action => "comments", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/diary/comments/1", :method => :get }, + { :controller => "diary_entry", :action => "comments", :display_name => "username", :page => "1" } + ) + + assert_routing( + { :path => "/diary/new", :method => :get }, + { :controller => "diary_entry", :action => "new" } + ) + assert_routing( + { :path => "/diary/new", :method => :post }, + { :controller => "diary_entry", :action => "new" } + ) + assert_routing( + { :path => "/user/username/diary/1", :method => :get }, + { :controller => "diary_entry", :action => "view", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/diary/1/edit", :method => :get }, + { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/diary/1/edit", :method => :post }, + { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/diary/1/newcomment", :method => :post }, + { :controller => "diary_entry", :action => "comment", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/diary/1/hide", :method => :post }, + { :controller => "diary_entry", :action => "hide", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/diary/1/hidecomment/2", :method => :post }, + { :controller => "diary_entry", :action => "hidecomment", :display_name => "username", :id => "1", :comment => "2" } + ) + end + def test_showing_new_diary_entry @request.cookies["_osm_username"] = users(:normal_user).display_name diff --git a/test/functional/export_controller_test.rb b/test/functional/export_controller_test.rb index 0fa6398c1..75ed34a4a 100644 --- a/test/functional/export_controller_test.rb +++ b/test/functional/export_controller_test.rb @@ -1,7 +1,20 @@ require File.dirname(__FILE__) + '/../test_helper' class ExportControllerTest < ActionController::TestCase - # Replace this with your real tests. + + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/export/start", :method => :get }, + { :controller => "export", :action => "start" } + ) + assert_routing( + { :path => "/export/finish", :method => :post }, + { :controller => "export", :action => "finish" } + ) + end + def test_start xhr :get, :start assert_response :success diff --git a/test/functional/geocoder_controller_test.rb b/test/functional/geocoder_controller_test.rb index f63fe518d..e9d07b24e 100644 --- a/test/functional/geocoder_controller_test.rb +++ b/test/functional/geocoder_controller_test.rb @@ -2,9 +2,57 @@ require File.dirname(__FILE__) + '/../test_helper' require 'geocoder_controller' class GeocoderControllerTest < ActionController::TestCase + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/geocoder/search", :method => :get }, + { :controller => "geocoder", :action => "search" } + ) + assert_routing( + { :path => "/geocoder/search_latlon", :method => :get }, + { :controller => "geocoder", :action => "search_latlon" } + ) + assert_routing( + { :path => "/geocoder/search_us_postcode", :method => :get }, + { :controller => "geocoder", :action => "search_us_postcode" } + ) + assert_routing( + { :path => "/geocoder/search_uk_postcode", :method => :get }, + { :controller => "geocoder", :action => "search_uk_postcode" } + ) + assert_routing( + { :path => "/geocoder/search_ca_postcode", :method => :get }, + { :controller => "geocoder", :action => "search_ca_postcode" } + ) + assert_routing( + { :path => "/geocoder/search_osm_namefinder", :method => :get }, + { :controller => "geocoder", :action => "search_osm_namefinder" } + ) + assert_routing( + { :path => "/geocoder/search_osm_nominatim", :method => :get }, + { :controller => "geocoder", :action => "search_osm_nominatim" } + ) + assert_routing( + { :path => "/geocoder/search_geonames", :method => :get }, + { :controller => "geocoder", :action => "search_geonames" } + ) - # Replace this with your real tests. - def test_truth - assert true + assert_routing( + { :path => "/geocoder/description", :method => :get }, + { :controller => "geocoder", :action => "description" } + ) + assert_routing( + { :path => "/geocoder/description_osm_namefinder", :method => :get }, + { :controller => "geocoder", :action => "description_osm_namefinder" } + ) + assert_routing( + { :path => "/geocoder/description_osm_nominatim", :method => :get }, + { :controller => "geocoder", :action => "description_osm_nominatim" } + ) + assert_routing( + { :path => "/geocoder/description_geonames", :method => :get }, + { :controller => "geocoder", :action => "description_geonames" } + ) end end diff --git a/test/functional/message_controller_test.rb b/test/functional/message_controller_test.rb index 96f509cb0..1a47f02d6 100644 --- a/test/functional/message_controller_test.rb +++ b/test/functional/message_controller_test.rb @@ -2,9 +2,40 @@ require File.dirname(__FILE__) + '/../test_helper' require 'message_controller' class MessageControllerTest < ActionController::TestCase - - # Replace this with your real tests. - def test_truth - assert true + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/user/username/inbox", :method => :get }, + { :controller => "message", :action => "inbox", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/outbox", :method => :get }, + { :controller => "message", :action => "outbox", :display_name => "username" } + ) + assert_routing( + { :path => "/message/new/username", :method => :get }, + { :controller => "message", :action => "new", :display_name => "username" } + ) + assert_routing( + { :path => "/message/new/username", :method => :post }, + { :controller => "message", :action => "new", :display_name => "username" } + ) + assert_routing( + { :path => "/message/read/1", :method => :get }, + { :controller => "message", :action => "read", :message_id => "1" } + ) + assert_routing( + { :path => "/message/mark/1", :method => :post }, + { :controller => "message", :action => "mark", :message_id => "1" } + ) + assert_routing( + { :path => "/message/reply/1", :method => :get }, + { :controller => "message", :action => "reply", :message_id => "1" } + ) + assert_routing( + { :path => "/message/delete/1", :method => :post }, + { :controller => "message", :action => "delete", :message_id => "1" } + ) end end diff --git a/test/functional/node_controller_test.rb b/test/functional/node_controller_test.rb index fdefd0896..5544728f1 100644 --- a/test/functional/node_controller_test.rb +++ b/test/functional/node_controller_test.rb @@ -3,6 +3,31 @@ require File.dirname(__FILE__) + '/../test_helper' class NodeControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/node/create", :method => :put }, + { :controller => "node", :action => "create" } + ) + assert_routing( + { :path => "/api/0.6/node/1", :method => :get }, + { :controller => "node", :action => "read", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/node/1", :method => :put }, + { :controller => "node", :action => "update", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/node/1", :method => :delete }, + { :controller => "node", :action => "delete", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/nodes", :method => :get }, + { :controller => "node", :action => "nodes" } + ) + end + def test_create # cannot read password from fixture as it is stored as MD5 digest ## First try with no auth diff --git a/test/functional/oauth_clients_controller_test.rb b/test/functional/oauth_clients_controller_test.rb new file mode 100644 index 000000000..64a1e4e72 --- /dev/null +++ b/test/functional/oauth_clients_controller_test.rb @@ -0,0 +1,36 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class OauthClientsControllerTest < ActionController::TestCase + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/user/username/oauth_clients", :method => :get }, + { :controller => "oauth_clients", :action => "index", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/oauth_clients/new", :method => :get }, + { :controller => "oauth_clients", :action => "new", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/oauth_clients", :method => :post }, + { :controller => "oauth_clients", :action => "create", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/oauth_clients/1", :method => :get }, + { :controller => "oauth_clients", :action => "show", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/oauth_clients/1/edit", :method => :get }, + { :controller => "oauth_clients", :action => "edit", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/oauth_clients/1", :method => :put }, + { :controller => "oauth_clients", :action => "update", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/oauth_clients/1", :method => :delete }, + { :controller => "oauth_clients", :action => "destroy", :display_name => "username", :id => "1" } + ) + end +end diff --git a/test/functional/oauth_controller_test.rb b/test/functional/oauth_controller_test.rb new file mode 100644 index 000000000..b34416be6 --- /dev/null +++ b/test/functional/oauth_controller_test.rb @@ -0,0 +1,32 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class OauthControllerTest < ActionController::TestCase + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/oauth/revoke" }, + { :controller => "oauth", :action => "revoke" } + ) + assert_routing( + { :path => "/oauth/authorize" }, + { :controller => "oauth", :action => "authorize" } + ) + assert_routing( + { :path => "/oauth/token" }, + { :controller => "oauth", :action => "token" } + ) + assert_routing( + { :path => "/oauth/request_token" }, + { :controller => "oauth", :action => "request_token" } + ) + assert_routing( + { :path => "/oauth/access_token" }, + { :controller => "oauth", :action => "access_token" } + ) + assert_routing( + { :path => "/oauth/test_request" }, + { :controller => "oauth", :action => "test_request" } + ) + end +end diff --git a/test/functional/old_node_controller_test.rb b/test/functional/old_node_controller_test.rb index 69ea0f345..3c0358c2b 100644 --- a/test/functional/old_node_controller_test.rb +++ b/test/functional/old_node_controller_test.rb @@ -8,6 +8,19 @@ class OldNodeControllerTest < ActionController::TestCase # TODO: test history # + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/node/1/history", :method => :get }, + { :controller => "old_node", :action => "history", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/node/1/2", :method => :get }, + { :controller => "old_node", :action => "version", :id => "1", :version => "2" } + ) + end + ## # test the version call by submitting several revisions of a new node # to the API and ensuring that later calls to version return the diff --git a/test/functional/old_relation_controller_test.rb b/test/functional/old_relation_controller_test.rb index 54e1cd037..89676a175 100644 --- a/test/functional/old_relation_controller_test.rb +++ b/test/functional/old_relation_controller_test.rb @@ -4,6 +4,19 @@ require 'old_relation_controller' class OldRelationControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/relation/1/history", :method => :get }, + { :controller => "old_relation", :action => "history", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relation/1/2", :method => :get }, + { :controller => "old_relation", :action => "version", :id => "1", :version => "2" } + ) + end + # ------------------------------------- # Test reading old relations. # ------------------------------------- diff --git a/test/functional/old_way_controller_test.rb b/test/functional/old_way_controller_test.rb index 9dd542c52..f0ab6bd85 100644 --- a/test/functional/old_way_controller_test.rb +++ b/test/functional/old_way_controller_test.rb @@ -4,6 +4,19 @@ require 'old_way_controller' class OldWayControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/way/1/history", :method => :get }, + { :controller => "old_way", :action => "history", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/way/1/2", :method => :get }, + { :controller => "old_way", :action => "version", :id => "1", :version => "2" } + ) + end + # ------------------------------------- # Test reading old ways. # ------------------------------------- diff --git a/test/functional/relation_controller_test.rb b/test/functional/relation_controller_test.rb index 8a59adb02..1f2640d46 100644 --- a/test/functional/relation_controller_test.rb +++ b/test/functional/relation_controller_test.rb @@ -4,6 +4,48 @@ require 'relation_controller' class RelationControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/relation/create", :method => :put }, + { :controller => "relation", :action => "create" } + ) + assert_routing( + { :path => "/api/0.6/relation/1/full", :method => :get }, + { :controller => "relation", :action => "full", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relation/1", :method => :get }, + { :controller => "relation", :action => "read", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relation/1", :method => :put }, + { :controller => "relation", :action => "update", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relation/1", :method => :delete }, + { :controller => "relation", :action => "delete", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relations", :method => :get }, + { :controller => "relation", :action => "relations" } + ) + + assert_routing( + { :path => "/api/0.6/node/1/relations", :method => :get }, + { :controller => "relation", :action => "relations_for_node", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/way/1/relations", :method => :get }, + { :controller => "relation", :action => "relations_for_way", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/relation/1/relations", :method => :get }, + { :controller => "relation", :action => "relations_for_relation", :id => "1" } + ) + end + # ------------------------------------- # Test reading relations. # ------------------------------------- diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index a213253ec..7fd060dc4 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -1,8 +1,24 @@ require File.dirname(__FILE__) + '/../test_helper' class SearchControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/search", :method => :get }, + { :controller => "search", :action => "search_all" } + ) + assert_routing( + { :path => "/api/0.6/nodes/search", :method => :get }, + { :controller => "search", :action => "search_nodes" } + ) + assert_routing( + { :path => "/api/0.6/ways/search", :method => :get }, + { :controller => "search", :action => "search_ways" } + ) + assert_routing( + { :path => "/api/0.6/relations/search", :method => :get }, + { :controller => "search", :action => "search_relations" } + ) end end diff --git a/test/functional/site_controller_test.rb b/test/functional/site_controller_test.rb index 4d2162a71..753e1c859 100644 --- a/test/functional/site_controller_test.rb +++ b/test/functional/site_controller_test.rb @@ -3,6 +3,55 @@ require File.dirname(__FILE__) + '/../test_helper' class SiteControllerTest < ActionController::TestCase fixtures :users + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/", :method => :get }, + { :controller => "site", :action => "index" } + ) + assert_recognizes( + { :controller => "site", :action => "index" }, + { :path => "/index.html", :method => :get } + ) + assert_routing( + { :path => "/edit", :method => :get }, + { :controller => "site", :action => "edit" } + ) + assert_recognizes( + { :controller => "site", :action => "edit", :format => "html" }, + { :path => "/edit.html", :method => :get } + ) + assert_routing( + { :path => "/copyright", :method => :get }, + { :controller => "site", :action => "copyright" } + ) + assert_routing( + { :path => "/copyright/locale", :method => :get }, + { :controller => "site", :action => "copyright", :copyright_locale => "locale" } + ) + assert_routing( + { :path => "/export", :method => :get }, + { :controller => "site", :action => "export" } + ) + assert_recognizes( + { :controller => "site", :action => "export", :format => "html" }, + { :path => "/export.html", :method => :get } + ) + assert_routing( + { :path => "/offline", :method => :get }, + { :controller => "site", :action => "offline" } + ) + assert_routing( + { :path => "/key", :method => :get }, + { :controller => "site", :action => "key" } + ) + assert_routing( + { :path => "/go/shortcode", :method => :get }, + { :controller => "site", :action => "permalink", :code => "shortcode" } + ) + end + ## Lets check that we can get all the pages without any errors # Get the index def test_index diff --git a/test/functional/swf_controller_test.rb b/test/functional/swf_controller_test.rb index 862d3a8f0..09b8f3aae 100644 --- a/test/functional/swf_controller_test.rb +++ b/test/functional/swf_controller_test.rb @@ -1,8 +1,12 @@ require File.dirname(__FILE__) + '/../test_helper' class SwfControllerTest < ActionController::TestCase - # Replace this with your real tests. - def test_truth - assert true + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/swf/trackpoints", :method => :get }, + { :controller => "swf", :action => "trackpoints" } + ) end end diff --git a/test/functional/trace_controller_test.rb b/test/functional/trace_controller_test.rb index 28c09c899..aca2a59d8 100644 --- a/test/functional/trace_controller_test.rb +++ b/test/functional/trace_controller_test.rb @@ -4,6 +4,148 @@ class TraceControllerTest < ActionController::TestCase fixtures :users, :gpx_files set_fixture_class :gpx_files => 'Trace' + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/gpx/create", :method => :post }, + { :controller => "trace", :action => "api_create" } + ) + assert_routing( + { :path => "/api/0.6/gpx/1", :method => :get }, + { :controller => "trace", :action => "api_read", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/gpx/1", :method => :put }, + { :controller => "trace", :action => "api_update", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/gpx/1", :method => :delete }, + { :controller => "trace", :action => "api_delete", :id => "1" } + ) + assert_recognizes( + { :controller => "trace", :action => "api_read", :id => "1" }, + { :path => "/api/0.6/gpx/1/details", :method => :get } + ) + assert_routing( + { :path => "/api/0.6/gpx/1/data", :method => :get }, + { :controller => "trace", :action => "api_data", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/gpx/1/data.xml", :method => :get }, + { :controller => "trace", :action => "api_data", :id => "1", :format => "xml" } + ) + + assert_routing( + { :path => "/traces", :method => :get }, + { :controller => "trace", :action => "list" } + ) + assert_routing( + { :path => "/traces/page/1", :method => :get }, + { :controller => "trace", :action => "list", :page => "1" } + ) + assert_routing( + { :path => "/traces/tag/tagname", :method => :get }, + { :controller => "trace", :action => "list", :tag => "tagname" } + ) + assert_routing( + { :path => "/traces/tag/tagname/page/1", :method => :get }, + { :controller => "trace", :action => "list", :tag => "tagname", :page => "1" } + ) + assert_routing( + { :path => "/user/username/traces", :method => :get }, + { :controller => "trace", :action => "list", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/traces/page/1", :method => :get }, + { :controller => "trace", :action => "list", :display_name => "username", :page => "1" } + ) + assert_routing( + { :path => "/user/username/traces/tag/tagname", :method => :get }, + { :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname" } + ) + assert_routing( + { :path => "/user/username/traces/tag/tagname/page/1", :method => :get }, + { :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname", :page => "1" } + ) + + assert_routing( + { :path => "/traces/mine", :method => :get }, + { :controller => "trace", :action => "mine" } + ) + assert_routing( + { :path => "/traces/mine/page/1", :method => :get }, + { :controller => "trace", :action => "mine", :page => "1" } + ) + assert_routing( + { :path => "/traces/mine/tag/tagname", :method => :get }, + { :controller => "trace", :action => "mine", :tag => "tagname" } + ) + assert_routing( + { :path => "/traces/mine/tag/tagname/page/1", :method => :get }, + { :controller => "trace", :action => "mine", :tag => "tagname", :page => "1" } + ) + + assert_routing( + { :path => "/traces/rss", :method => :get }, + { :controller => "trace", :action => "georss" } + ) + assert_routing( + { :path => "/traces/tag/tagname/rss", :method => :get }, + { :controller => "trace", :action => "georss", :tag => "tagname" } + ) + assert_routing( + { :path => "/user/username/traces/rss", :method => :get }, + { :controller => "trace", :action => "georss", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/traces/tag/tagname/rss", :method => :get }, + { :controller => "trace", :action => "georss", :display_name => "username", :tag => "tagname" } + ) + + assert_routing( + { :path => "/user/username/traces/1", :method => :get }, + { :controller => "trace", :action => "view", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/traces/1/picture", :method => :get }, + { :controller => "trace", :action => "picture", :display_name => "username", :id => "1" } + ) + assert_routing( + { :path => "/user/username/traces/1/icon", :method => :get }, + { :controller => "trace", :action => "icon", :display_name => "username", :id => "1" } + ) + + assert_routing( + { :path => "/trace/create", :method => :get }, + { :controller => "trace", :action => "create" } + ) + assert_routing( + { :path => "/trace/create", :method => :post }, + { :controller => "trace", :action => "create" } + ) + assert_routing( + { :path => "/trace/1/data", :method => :get }, + { :controller => "trace", :action => "data", :id => "1" } + ) + assert_routing( + { :path => "/trace/1/data.xml", :method => :get }, + { :controller => "trace", :action => "data", :id => "1", :format => "xml" } + ) + assert_routing( + { :path => "/trace/1/edit", :method => :get }, + { :controller => "trace", :action => "edit", :id => "1" } + ) + assert_routing( + { :path => "/trace/1/edit", :method => :post }, + { :controller => "trace", :action => "edit", :id => "1" } + ) + assert_routing( + { :path => "/trace/1/delete", :method => :post }, + { :controller => "trace", :action => "delete", :id => "1" } + ) + end + # Check that the list of changesets is displayed def test_list get :list diff --git a/test/functional/user_blocks_controller_test.rb b/test/functional/user_blocks_controller_test.rb new file mode 100644 index 000000000..adf0f3631 --- /dev/null +++ b/test/functional/user_blocks_controller_test.rb @@ -0,0 +1,58 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class UserBlocksControllerTest < ActionController::TestCase + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/blocks/new/username", :method => :get }, + { :controller => "user_blocks", :action => "new", :display_name => "username" } + ) + + assert_routing( + { :path => "/user_blocks", :method => :get }, + { :controller => "user_blocks", :action => "index" } + ) + assert_routing( + { :path => "/user_blocks/new", :method => :get }, + { :controller => "user_blocks", :action => "new" } + ) + assert_routing( + { :path => "/user_blocks", :method => :post }, + { :controller => "user_blocks", :action => "create" } + ) + assert_routing( + { :path => "/user_blocks/1", :method => :get }, + { :controller => "user_blocks", :action => "show", :id => "1" } + ) + assert_routing( + { :path => "/user_blocks/1/edit", :method => :get }, + { :controller => "user_blocks", :action => "edit", :id => "1" } + ) + assert_routing( + { :path => "/user_blocks/1", :method => :put }, + { :controller => "user_blocks", :action => "update", :id => "1" } + ) + assert_routing( + { :path => "/user_blocks/1", :method => :delete }, + { :controller => "user_blocks", :action => "destroy", :id => "1" } + ) + assert_routing( + { :path => "/blocks/1/revoke", :method => :get }, + { :controller => "user_blocks", :action => "revoke", :id => "1" } + ) + assert_routing( + { :path => "/blocks/1/revoke", :method => :post }, + { :controller => "user_blocks", :action => "revoke", :id => "1" } + ) + + assert_routing( + { :path => "/user/username/blocks", :method => :get }, + { :controller => "user_blocks", :action => "blocks_on", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/blocks_by", :method => :get }, + { :controller => "user_blocks", :action => "blocks_by", :display_name => "username" } + ) + end +end diff --git a/test/functional/user_controller_test.rb b/test/functional/user_controller_test.rb index 309eb5e24..24daa1a6c 100644 --- a/test/functional/user_controller_test.rb +++ b/test/functional/user_controller_test.rb @@ -3,6 +3,178 @@ require File.dirname(__FILE__) + '/../test_helper' class UserControllerTest < ActionController::TestCase fixtures :users + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/user/details", :method => :get }, + { :controller => "user", :action => "api_details" } + ) + assert_routing( + { :path => "/api/0.6/user/gpx_files", :method => :get }, + { :controller => "user", :action => "api_gpx_files" } + ) + + assert_routing( + { :path => "/login", :method => :get }, + { :controller => "user", :action => "login" } + ) + assert_routing( + { :path => "/login", :method => :post }, + { :controller => "user", :action => "login" } + ) + assert_recognizes( + { :controller => "user", :action => "login", :format => "html" }, + { :path => "/login.html", :method => :get } + ) + + assert_routing( + { :path => "/logout", :method => :get }, + { :controller => "user", :action => "logout" } + ) + assert_routing( + { :path => "/logout", :method => :post }, + { :controller => "user", :action => "logout" } + ) + assert_recognizes( + { :controller => "user", :action => "logout", :format => "html" }, + { :path => "/logout.html", :method => :get } + ) + + assert_routing( + { :path => "/user/new", :method => :get }, + { :controller => "user", :action => "new" } + ) + assert_recognizes( + { :controller => "user", :action => "new" }, + { :path => "/create-account.html", :method => :get } + ) + + assert_routing( + { :path => "/user/terms", :method => :get }, + { :controller => "user", :action => "terms" } + ) + assert_routing( + { :path => "/user/terms", :method => :post }, + { :controller => "user", :action => "terms" } + ) + + assert_routing( + { :path => "/user/save", :method => :post }, + { :controller => "user", :action => "save" } + ) + + assert_routing( + { :path => "/user/username/confirm", :method => :get }, + { :controller => "user", :action => "confirm", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/confirm", :method => :post }, + { :controller => "user", :action => "confirm", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/confirm/resend", :method => :get }, + { :controller => "user", :action => "confirm_resend", :display_name => "username" } + ) + + assert_routing( + { :path => "/user/confirm", :method => :get }, + { :controller => "user", :action => "confirm" } + ) + assert_routing( + { :path => "/user/confirm", :method => :post }, + { :controller => "user", :action => "confirm" } + ) + assert_routing( + { :path => "/user/confirm-email", :method => :get }, + { :controller => "user", :action => "confirm_email" } + ) + assert_routing( + { :path => "/user/confirm-email", :method => :post }, + { :controller => "user", :action => "confirm_email" } + ) + + assert_routing( + { :path => "/user/go_public", :method => :post }, + { :controller => "user", :action => "go_public" } + ) + + assert_routing( + { :path => "/user/forgot-password", :method => :get }, + { :controller => "user", :action => "lost_password" } + ) + assert_routing( + { :path => "/user/forgot-password", :method => :post }, + { :controller => "user", :action => "lost_password" } + ) + assert_recognizes( + { :controller => "user", :action => "lost_password" }, + { :path => "/forgot-password.html", :method => :get } + ) + assert_routing( + { :path => "/user/reset-password", :method => :get }, + { :controller => "user", :action => "reset_password" } + ) + assert_routing( + { :path => "/user/reset-password", :method => :post }, + { :controller => "user", :action => "reset_password" } + ) + + assert_routing( + { :path => "/user/suspended", :method => :get }, + { :controller => "user", :action => "suspended" } + ) + + assert_routing( + { :path => "/user/username", :method => :get }, + { :controller => "user", :action => "view", :display_name => "username" } + ) + + assert_routing( + { :path => "/user/username/account", :method => :get }, + { :controller => "user", :action => "account", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/account", :method => :post }, + { :controller => "user", :action => "account", :display_name => "username" } + ) + + assert_routing( + { :path => "/user/username/make_friend", :method => :get }, + { :controller => "user", :action => "make_friend", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/remove_friend", :method => :get }, + { :controller => "user", :action => "remove_friend", :display_name => "username" } + ) + + assert_routing( + { :path => "/user/username/set_status", :method => :get }, + { :controller => "user", :action => "set_status", :display_name => "username" } + ) + assert_routing( + { :path => "/user/username/delete", :method => :get }, + { :controller => "user", :action => "delete", :display_name => "username" } + ) + + assert_routing( + { :path => "/users", :method => :get }, + { :controller => "user", :action => "list" } + ) + assert_routing( + { :path => "/users", :method => :post }, + { :controller => "user", :action => "list" } + ) + assert_routing( + { :path => "/users/status", :method => :get }, + { :controller => "user", :action => "list", :status => "status" } + ) + assert_routing( + { :path => "/users/status", :method => :post }, + { :controller => "user", :action => "list", :status => "status" } + ) + end + # The user creation page loads def test_user_create_view get :new diff --git a/test/functional/user_preference_controller_test.rb b/test/functional/user_preference_controller_test.rb index 2c6ca446b..3921fe536 100644 --- a/test/functional/user_preference_controller_test.rb +++ b/test/functional/user_preference_controller_test.rb @@ -2,7 +2,32 @@ require File.dirname(__FILE__) + '/../test_helper' class UserPreferenceControllerTest < ActionController::TestCase fixtures :users, :user_preferences - + + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/user/preferences", :method => :get }, + { :controller => "user_preference", :action => "read" } + ) + assert_routing( + { :path => "/api/0.6/user/preferences", :method => :put }, + { :controller => "user_preference", :action => "update" } + ) + assert_routing( + { :path => "/api/0.6/user/preferences/key", :method => :get }, + { :controller => "user_preference", :action => "read_one", :preference_key => "key" } + ) + assert_routing( + { :path => "/api/0.6/user/preferences/key", :method => :put }, + { :controller => "user_preference", :action => "update_one", :preference_key => "key" } + ) + assert_routing( + { :path => "/api/0.6/user/preferences/key", :method => :delete }, + { :controller => "user_preference", :action => "delete_one", :preference_key => "key" } + ) + end + def test_read # first try without auth get :read @@ -21,5 +46,4 @@ class UserPreferenceControllerTest < ActionController::TestCase end end end - end diff --git a/test/functional/user_roles_controller_test.rb b/test/functional/user_roles_controller_test.rb new file mode 100644 index 000000000..1e2d29b45 --- /dev/null +++ b/test/functional/user_roles_controller_test.rb @@ -0,0 +1,24 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class UserRolesControllerTest < ActionController::TestCase + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/user/username/role/rolename/grant", :method => :get }, + { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" } + ) + assert_routing( + { :path => "/user/username/role/rolename/grant", :method => :post }, + { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" } + ) + assert_routing( + { :path => "/user/username/role/rolename/revoke", :method => :get }, + { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" } + ) + assert_routing( + { :path => "/user/username/role/rolename/revoke", :method => :post }, + { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" } + ) + end +end diff --git a/test/functional/way_controller_test.rb b/test/functional/way_controller_test.rb index bba13062c..a4b5a192a 100644 --- a/test/functional/way_controller_test.rb +++ b/test/functional/way_controller_test.rb @@ -4,6 +4,35 @@ require 'way_controller' class WayControllerTest < ActionController::TestCase api_fixtures + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/api/0.6/way/create", :method => :put }, + { :controller => "way", :action => "create" } + ) + assert_routing( + { :path => "/api/0.6/way/1/full", :method => :get }, + { :controller => "way", :action => "full", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/way/1", :method => :get }, + { :controller => "way", :action => "read", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/way/1", :method => :put }, + { :controller => "way", :action => "update", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/way/1", :method => :delete }, + { :controller => "way", :action => "delete", :id => "1" } + ) + assert_routing( + { :path => "/api/0.6/ways", :method => :get }, + { :controller => "way", :action => "ways" } + ) + end + # ------------------------------------- # Test reading ways. # ------------------------------------- -- 2.43.2