require File.dirname(__FILE__) + '/../test_helper'
require 'relation_controller'
-# Re-raise errors caught by the controller.
-class RelationController; def rescue_action(e) raise e end; end
-
-class RelationControllerTest < Test::Unit::TestCase
+class RelationControllerTest < ActionController::TestCase
api_fixtures
- def setup
- @controller = RelationController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
-
def basic_authorization(user, pass)
@request.env["HTTP_AUTHORIZATION"] = "Basic %s" % Base64.encode64("#{user}:#{pass}")
end
get :relations_for_node, :id => node_id
assert_response :success
+ # the results we expect
+ expected_relations = [ :visible_relation, :used_relation ]
+
# count one osm element
assert_select "osm[version=#{API_VERSION}][generator=\"OpenStreetMap server\"]", 1
- # we should have only two relations
- assert_select "osm>relation", 2
+ # we should have only the expected number of relations
+ assert_select "osm>relation", expected_relations.size
# and each of them should contain the node we originally searched for
- [ :visible_relation,
- :used_relation ].each do |r|
+ expected_relations.each do |r|
relation_id = current_relations(r).id
assert_select "osm>relation#?", relation_id
assert_select "osm>relation#?>member[type=\"node\"][ref=#{node_id}]", relation_id