]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/old_way_controller_test.rb
Add routing tests for all supported routes
[rails.git] / test / functional / old_way_controller_test.rb
index c6d4ce240180d351d3b7c99c7072c1770c277944..f0ab6bd859409fc0fb3452dd8af335a25bebea60 100644 (file)
@@ -1,16 +1,20 @@
 require File.dirname(__FILE__) + '/../test_helper'
 require 'old_way_controller'
 
 require File.dirname(__FILE__) + '/../test_helper'
 require 'old_way_controller'
 
-# Re-raise errors caught by the controller.
-class OldWayController; def rescue_action(e) raise e end; end
-
-class OldWayControllerTest < Test::Unit::TestCase
+class OldWayControllerTest < ActionController::TestCase
   api_fixtures
 
   api_fixtures
 
-  def setup
-    @controller = OldWayController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
+  ##
+  # 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
 
   # -------------------------------------
   end
 
   # -------------------------------------
@@ -19,13 +23,13 @@ class OldWayControllerTest < Test::Unit::TestCase
 
   def test_history_visible
     # check that a visible way is returned properly
 
   def test_history_visible
     # check that a visible way is returned properly
-    get :history, :id => ways(:visible_way).id
+    get :history, :id => ways(:visible_way).way_id
     assert_response :success
   end
   
   def test_history_invisible
     # check that an invisible way's history is returned properly
     assert_response :success
   end
   
   def test_history_invisible
     # check that an invisible way's history is returned properly
-    get :history, :id => ways(:invisible_way).id
+    get :history, :id => ways(:invisible_way).way_id
     assert_response :success
   end
   
     assert_response :success
   end
   
@@ -74,7 +78,8 @@ class OldWayControllerTest < Test::Unit::TestCase
   end
 
   ##
   end
 
   ##
-  #
+  # look at all the versions of the way in the history and get each version from
+  # the versions call. check that they're the same.
   def check_history_equals_versions(way_id)
     get :history, :id => way_id
     assert_response :success, "can't get way #{way_id} from API"
   def check_history_equals_versions(way_id)
     get :history, :id => way_id
     assert_response :success, "can't get way #{way_id} from API"
@@ -94,16 +99,4 @@ class OldWayControllerTest < Test::Unit::TestCase
     end
   end
 
     end
   end
 
-  ##
-  # for some reason assert_equal a, b fails when the ways are actually
-  # equal, so this method manually checks the fields...
-  def assert_ways_are_equal(a, b)
-    assert_equal a.id, b.id, "way IDs"
-    assert_equal a.changeset_id, b.changeset_id, "changeset ID on way #{a.id}"
-    assert_equal a.visible, b.visible, "visible on way #{a.id}"
-    assert_equal a.version, b.version, "version on way #{a.id}"
-    assert_equal a.tags, b.tags, "tags on way #{a.id}"
-    assert_equal a.nds, b.nds, "node references on way #{a.id}"
-  end
-
 end
 end