- add old_relation_controller and stuff so that relation history works. fixes #557.
- minor testing fixes.
This commit is contained in:
parent
a03c584a98
commit
d0aa199e92
8 changed files with 103 additions and 3 deletions
23
app/controllers/old_relation_controller.rb
Normal file
23
app/controllers/old_relation_controller.rb
Normal file
|
@ -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
|
3
app/controllers/old_relation_member_controller.rb
Normal file
3
app/controllers/old_relation_member_controller.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class OldRelationMemberController < ApplicationController
|
||||
|
||||
end
|
3
app/controllers/old_relation_tag_controller.rb
Normal file
3
app/controllers/old_relation_tag_controller.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class OldRelationTagController < ApplicationController
|
||||
|
||||
end
|
|
@ -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
|
||||
|
|
31
test/functional/old_relation_controller_test.rb
Normal file
31
test/functional/old_relation_controller_test.rb
Normal file
|
@ -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
|
31
test/functional/old_way_controller_test.rb
Normal file
31
test/functional/old_way_controller_test.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue