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
# 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.
# -------------------------------------
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
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
# -----------------------
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
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
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
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
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
--- /dev/null
+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
--- /dev/null
+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
# 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
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.
# -------------------------------------
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.
# -------------------------------------
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.
# -------------------------------------
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
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
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
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
--- /dev/null
+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
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
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
end
end
end
-
end
--- /dev/null
+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
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.
# -------------------------------------