]> git.openstreetmap.org Git - rails.git/commitdiff
- add old_relation_controller and stuff so that relation history works. fixes #557.
authorFrederik Ramm <frederik@remote.org>
Sun, 16 Mar 2008 23:16:18 +0000 (23:16 +0000)
committerFrederik Ramm <frederik@remote.org>
Sun, 16 Mar 2008 23:16:18 +0000 (23:16 +0000)
- minor testing fixes.

app/controllers/old_relation_controller.rb [new file with mode: 0644]
app/controllers/old_relation_member_controller.rb [new file with mode: 0644]
app/controllers/old_relation_tag_controller.rb [new file with mode: 0644]
test/functional/node_controller_test.rb
test/functional/old_relation_controller_test.rb [new file with mode: 0644]
test/functional/old_way_controller_test.rb [new file with mode: 0644]
test/functional/relation_controller_test.rb
test/test_helper.rb

diff --git a/app/controllers/old_relation_controller.rb b/app/controllers/old_relation_controller.rb
new file mode 100644 (file)
index 0000000..0b5aa89
--- /dev/null
@@ -0,0 +1,23 @@
+class OldRelationController < ApplicationController
+  require 'xml/libxml'
+
+  session :off
+  after_filter :compress_output
+
+  def history
+    begin
+      relation = Relation.find(params[:id])
+      doc = OSM::API.new.get_xml_doc
+
+      relation.old_relations.each do |old_relation|
+        doc.root << old_relation.to_xml_node
+      end
+
+      render :text => doc.to_s, :content_type => "text/xml"
+    rescue ActiveRecord::RecordNotFound
+      render :nothing => true, :status => :not_found
+    rescue
+      render :nothing => true, :status => :internal_server_error
+    end
+  end
+end
diff --git a/app/controllers/old_relation_member_controller.rb b/app/controllers/old_relation_member_controller.rb
new file mode 100644 (file)
index 0000000..d7023ab
--- /dev/null
@@ -0,0 +1,3 @@
+class OldRelationMemberController < ApplicationController
+
+end
diff --git a/app/controllers/old_relation_tag_controller.rb b/app/controllers/old_relation_tag_controller.rb
new file mode 100644 (file)
index 0000000..fba59a0
--- /dev/null
@@ -0,0 +1,3 @@
+class OldRelationTagController < ApplicationController
+
+end
index bd1be9e69931b9cf75fc253da28c9cdd2ff5a344..a380eeb208313f08672104595eef0d188ec72e06 100644 (file)
@@ -28,8 +28,8 @@ class NodeControllerTest < Test::Unit::TestCase
     checknode = Node.find(nodeid)
     assert_not_nil checknode, "uploaded node not found in data base after upload"
     # compare values
-    assert_in_delta lat, checknode.latitude, 1E-8, "saved node does not match requested latitude"
-    assert_in_delta lon, checknode.longitude, 1E-8, "saved node does not match requested longitude"
+    assert_in_delta lat * 10000000, checknode.latitude, 1, "saved node does not match requested latitude"
+    assert_in_delta lon * 10000000, checknode.longitude, 1, "saved node does not match requested longitude"
     assert_equal users(:normal_user).id, checknode.user_id, "saved node does not belong to user that created it"
     assert_equal true, checknode.visible, "saved node is not visible"
   end
diff --git a/test/functional/old_relation_controller_test.rb b/test/functional/old_relation_controller_test.rb
new file mode 100644 (file)
index 0000000..b8bf464
--- /dev/null
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'old_relation_controller'
+
+# Re-raise errors caught by the controller.
+#class OldRelationController; def rescue_action(e) raise e end; end
+
+class OldRelationControllerTest < Test::Unit::TestCase
+  api_fixtures
+
+  def setup
+    @controller = OldRelationController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+  end
+
+  # -------------------------------------
+  # Test reading old relations.
+  # -------------------------------------
+
+  def test_history
+    # check that a visible relations is returned properly
+    get :history, :id => relations(:visible_relation).id
+    assert_response :success
+
+    # check chat a non-existent relations is not returned
+    get :history, :id => 0
+    assert_response :not_found
+
+  end
+
+end
diff --git a/test/functional/old_way_controller_test.rb b/test/functional/old_way_controller_test.rb
new file mode 100644 (file)
index 0000000..374ea7d
--- /dev/null
@@ -0,0 +1,31 @@
+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
+  api_fixtures
+
+  def setup
+    @controller = OldWayController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+  end
+
+  # -------------------------------------
+  # Test reading old ways.
+  # -------------------------------------
+
+  def test_history
+    # check that a visible way is returned properly
+    get :history, :id => ways(:visible_way).id
+    assert_response :success
+
+    # check chat a non-existent way is not returned
+    get :history, :id => 0
+    assert_response :not_found
+
+  end
+
+end
index 8f8b7277018eff50e43bea2fde6352c8437a0838..202a015a87f737459b13ec30a4055e9dc5c67a37 100644 (file)
@@ -57,7 +57,6 @@ class RelationControllerTest < Test::Unit::TestCase
         print @response.body
     end
 
-
     # check the "relations for relation" mode
     get :relations_for_relation, :id => current_relations(:used_relation).id
     assert_response :success
index f3baf4ff29042fad56614ab21c8bda3b9183b212..b1d7a8fcc280dec9ac39ddbbad7c90de4adf0c2c 100644 (file)
@@ -41,6 +41,16 @@ class Test::Unit::TestCase
     set_fixture_class :ways => :OldWay
     set_fixture_class :way_nodes => :OldWayNode
     set_fixture_class :way_tags => :OldWayTag
+
+    fixtures :current_relations, :current_relation_members, :current_relation_tags
+    set_fixture_class :current_relations => :Relation
+    set_fixture_class :current_relation_members => :RelationMember
+    set_fixture_class :current_relation_tags => :RelationTag
+
+    fixtures :relations, :relation_members, :relation_tags
+    set_fixture_class :relations => :OldRelation
+    set_fixture_class :relation_members => :OldRelationMember
+    set_fixture_class :relation_tags => :OldRelationTag
   end
 
   # Add more helper methods to be used by all tests here...