]> git.openstreetmap.org Git - rails.git/commitdiff
Add routing tests for all supported routes
authorTom Hughes <tom@compton.nu>
Fri, 9 Mar 2012 18:28:06 +0000 (18:28 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 9 Mar 2012 19:49:44 +0000 (19:49 +0000)
24 files changed:
test/functional/amf_controller_test.rb
test/functional/api_controller_test.rb
test/functional/browse_controller_test.rb
test/functional/changeset_controller_test.rb
test/functional/diary_entry_controller_test.rb
test/functional/export_controller_test.rb
test/functional/geocoder_controller_test.rb
test/functional/message_controller_test.rb
test/functional/node_controller_test.rb
test/functional/oauth_clients_controller_test.rb [new file with mode: 0644]
test/functional/oauth_controller_test.rb [new file with mode: 0644]
test/functional/old_node_controller_test.rb
test/functional/old_relation_controller_test.rb
test/functional/old_way_controller_test.rb
test/functional/relation_controller_test.rb
test/functional/search_controller_test.rb
test/functional/site_controller_test.rb
test/functional/swf_controller_test.rb
test/functional/trace_controller_test.rb
test/functional/user_blocks_controller_test.rb [new file with mode: 0644]
test/functional/user_controller_test.rb
test/functional/user_preference_controller_test.rb
test/functional/user_roles_controller_test.rb [new file with mode: 0644]
test/functional/way_controller_test.rb

index 8bef10bd15628d41cc9d9270d62aa7260d063580..46ff71eb734aad0ba57a3220105dd2870d6ba044 100644 (file)
@@ -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
index 9226e38926e8195c082fbfcbda2e379efd0b9239..adc433fe07b44c7663b44ab4cc4bde07ab7d930b 100644 (file)
@@ -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.
   # -------------------------------------
index f4da4c1a84b27cba9fcc95c7249299607b5318da..04b690ebf0119e3eb4816f51410503518e4d934c 100644 (file)
@@ -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
index ef80433403e05b0d11ffc615159053aa10b37d6a..a586b3dee77ea43b9e30effa7e784afc7e2e83a9 100644 (file)
@@ -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
   # -----------------------
index 738fbe67110e0f6dc8a23abd8cb8f7db50bb2845..54b4cdf7e713e8ecf5b836e3fde25aec04270b28 100644 (file)
@@ -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
 
index 0fa6398c16d0bd4aff69c220539740c284f59863..75ed34a4aa1d403fcaed7e506690eaeff79377a2 100644 (file)
@@ -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
index f63fe518d0aa04925c04f91b2e45ad905f145013..e9d07b24ed02972f8e4ca0323827cf4633218c99 100644 (file)
@@ -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
index 96f509cb0208b3548753e4fd5f351bdf65822b4c..1a47f02d620e25c39a9de7c5f92617e211d50d82 100644 (file)
@@ -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
index fdefd0896065f2dc521f31f4f41bce72ff9e77a0..5544728f194b9ae624e2c0fac27f4e6fbfb03f30 100644 (file)
@@ -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 (file)
index 0000000..64a1e4e
--- /dev/null
@@ -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 (file)
index 0000000..b34416b
--- /dev/null
@@ -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
index 69ea0f345720a6e1d821c7bde8f5894c21d9e3fc..3c0358c2b9a7465704c953390ea017d9e1aba0d2 100644 (file)
@@ -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 
index 54e1cd037fad660bfc39ef2e4604b18db6550d20..89676a175a8f38872f0455246ab96de4dede3135 100644 (file)
@@ -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.
   # -------------------------------------
index 9dd542c525490856d9c826df7ae67d075e350273..f0ab6bd859409fc0fb3452dd8af335a25bebea60 100644 (file)
@@ -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.
   # -------------------------------------
index 8a59adb027cb28f3f6945591a5272ebb7dcf2b36..1f2640d4615ce728feabd965b57e5cbd94ab631a 100644 (file)
@@ -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.
   # -------------------------------------
index a213253ecd62cb6e854be8f7d789bdd58e470006..7fd060dc4548c98c714dc46c63c581ccddd6d195 100644 (file)
@@ -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
index 4d2162a7161269985daf7cbb54a9a8509232af58..753e1c859b0536b56d905547819804858b0c9ac7 100644 (file)
@@ -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
index 862d3a8f02b9d73e315819c33b2084c13648ac32..09b8f3aae32634dac8eeec5f96464485eea6ecc1 100644 (file)
@@ -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
index 28c09c8995c96d42acf8cd839bd40e0bdb0e4e78..aca2a59d835dba6ce126d6a0a3307f9ccccae9a9 100644 (file)
@@ -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 (file)
index 0000000..adf0f36
--- /dev/null
@@ -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
index 309eb5e24ee41e3f93653a108887c86e0964e935..24daa1a6c708a718f8240d276aad3dc607e30687 100644 (file)
@@ -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
index 2c6ca446bde6316a56ce906286fae651acca9747..3921fe5362e322580b3b3ae33609a5835e5cbda2 100644 (file)
@@ -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 (file)
index 0000000..1e2d29b
--- /dev/null
@@ -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
index bba13062c0de9daa3c19c12cd75aa5fa48a44f77..a4b5a192a1bdafd7ea64e103bd5b5b9dbb516a98 100644 (file)
@@ -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.
   # -------------------------------------