]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/old_ways_controller_test.rb
Merge remote-tracking branch 'upstream/pull/5637'
[rails.git] / test / controllers / api / old_ways_controller_test.rb
index 6cfa1d3d8b960e6bc9d362644a8b5cbde59eeccf..a00dd84cf127a0bbbd90a917b1cdab3a38677e4c 100644 (file)
@@ -80,24 +80,28 @@ module Api
                     "redacted node #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history, even when logged in."
     end
 
-    ##
-    # check that we can retrieve versions of a way
     def test_show
-      way = create(:way, :with_history)
-      used_way = create(:way, :with_history)
-      create(:relation_member, :member => used_way)
-      way_with_versions = create(:way, :with_history, :version => 4)
+      way = create(:way, :with_history, :version => 2)
 
-      create(:way_tag, :way => way)
-      create(:way_tag, :way => used_way)
-      create(:way_tag, :way => way_with_versions)
-      propagate_tags(way, way.old_ways.last)
-      propagate_tags(used_way, used_way.old_ways.last)
-      propagate_tags(way_with_versions, way_with_versions.old_ways.last)
+      get api_way_version_path(way, 1)
 
-      check_current_version(way.id)
-      check_current_version(used_way.id)
-      check_current_version(way_with_versions.id)
+      assert_response :success
+      assert_dom "osm:root", 1 do
+        assert_dom "> way", 1 do
+          assert_dom "> @id", way.id.to_s
+          assert_dom "> @version", "1"
+        end
+      end
+
+      get api_way_version_path(way, 2)
+
+      assert_response :success
+      assert_dom "osm:root", 1 do
+        assert_dom "> way", 1 do
+          assert_dom "> @id", way.id.to_s
+          assert_dom "> @version", "2"
+        end
+      end
     end
 
     ##
@@ -309,27 +313,6 @@ module Api
 
     private
 
-    ##
-    # check that the current version of a way is equivalent to the
-    # version which we're getting from the versions call.
-    def check_current_version(way_id)
-      # get the current version
-      current_way = with_controller(WaysController.new) do
-        get api_way_path(way_id)
-        assert_response :success, "can't get current way #{way_id}"
-        Way.from_xml(@response.body)
-      end
-      assert_not_nil current_way, "getting way #{way_id} returned nil"
-
-      # get the "old" version of the way from the version method
-      get api_way_version_path(way_id, current_way.version)
-      assert_response :success, "can't get old way #{way_id}, v#{current_way.version}"
-      old_way = Way.from_xml(@response.body)
-
-      # check that the ways are identical
-      assert_ways_are_equal current_way, old_way
-    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.
@@ -365,11 +348,5 @@ module Api
       # now redact it
       post way_version_redact_path(way.way_id, way.version), :params => { :redaction => redaction.id }, :headers => headers
     end
-
-    def propagate_tags(way, old_way)
-      way.tags.each do |k, v|
-        create(:old_way_tag, :old_way => old_way, :k => k, :v => v)
-      end
-    end
   end
 end