)
assert_routing(
{ :path => "/api/0.6/relation/1", :method => :get },
- { :controller => "relations", :action => "read", :id => "1" }
+ { :controller => "relations", :action => "show", :id => "1" }
)
assert_routing(
{ :path => "/api/0.6/relation/1", :method => :put },
)
assert_routing(
{ :path => "/api/0.6/relations", :method => :get },
- { :controller => "relations", :action => "relations" }
+ { :controller => "relations", :action => "index" }
)
assert_routing(
end
# -------------------------------------
- # Test reading relations.
+ # Test showing relations.
# -------------------------------------
- def test_read
+ def test_show
# check that a visible relation is returned properly
- get :read, :params => { :id => create(:relation).id }
+ get :show, :params => { :id => create(:relation).id }
assert_response :success
# check that an invisible relation is not returned
- get :read, :params => { :id => create(:relation, :deleted).id }
+ get :show, :params => { :id => create(:relation, :deleted).id }
assert_response :gone
# check chat a non-existent relation is not returned
- get :read, :params => { :id => 0 }
+ get :show, :params => { :id => 0 }
assert_response :not_found
end
##
# test fetching multiple relations
- def test_relations
+ def test_index
relation1 = create(:relation)
relation2 = create(:relation, :deleted)
relation3 = create(:relation, :with_history, :version => 2)
relation4.old_relations.find_by(:version => 1).redact!(create(:redaction))
# check error when no parameter provided
- get :relations
+ get :index
assert_response :bad_request
# check error when no parameter value provided
- get :relations, :params => { :relations => "" }
+ get :index, :params => { :relations => "" }
assert_response :bad_request
# test a working call
- get :relations, :params => { :relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}" }
+ get :index, :params => { :relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}" }
assert_response :success
assert_select "osm" do
assert_select "relation", :count => 4
end
# check error when a non-existent relation is included
- get :relations, :params => { :relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id},0" }
+ get :index, :params => { :relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id},0" }
assert_response :not_found
end
assert_equal true, checkrelation.visible,
"saved relation is not visible"
# ok the relation is there but can we also retrieve it?
- get :read, :params => { :id => relationid }
+ get :show, :params => { :id => relationid }
assert_response :success
###
"saved relation is not visible"
# ok the relation is there but can we also retrieve it?
- get :read, :params => { :id => relationid }
+ get :show, :params => { :id => relationid }
assert_response :success
###
"saved relation is not visible"
# ok the relation is there but can we also retrieve it?
- get :read, :params => { :id => relationid }
+ get :show, :params => { :id => relationid }
assert_response :success
###
assert_equal true, checkrelation.visible,
"saved relation is not visible"
# ok the relation is there but can we also retrieve it?
- get :read, :params => { :id => relationid }
+ get :show, :params => { :id => relationid }
assert_response :success
end
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
# get it back and check the ordering
- get :read, :params => { :id => relation.id }
+ get :show, :params => { :id => relation.id }
assert_response :success, "can't read back the relation: #{@response.body}"
check_ordering(relation_xml, @response.body)
end
relation_id = @response.body.to_i
# get it back and check the ordering
- get :read, :params => { :id => relation_id }
+ get :show, :params => { :id => relation_id }
assert_response :success, "can't read back the relation: #{@response.body}"
check_ordering(doc, @response.body)
assert_equal 2, @response.body.to_i
# get it back again and check the ordering again
- get :read, :params => { :id => relation_id }
+ get :show, :params => { :id => relation_id }
assert_response :success, "can't read back the relation: #{@response.body}"
check_ordering(doc, @response.body)
relation_id = @response.body.to_i
# get it back and check the ordering
- get :read, :params => { :id => relation_id }
+ get :show, :params => { :id => relation_id }
assert_response :success, "can't read back the relation: #{relation_id}"
check_ordering(doc, @response.body)
end
relation_id = @response.body.to_i
# check the ordering in the current tables:
- get :read, :params => { :id => relation_id }
+ get :show, :params => { :id => relation_id }
assert_response :success, "can't read back the relation: #{@response.body}"
check_ordering(doc, @response.body)
# now download the changeset to check its bounding box
with_controller(ChangesetsController.new) do
- get :read, :params => { :id => changeset_id }
+ get :show, :params => { :id => changeset_id }
assert_response :success, "can't re-read changeset for modify test"
assert_select "osm>changeset", 1, "Changeset element doesn't exist in #{@response.body}"
assert_select "osm>changeset[id='#{changeset_id}']", 1, "Changeset id=#{changeset_id} doesn't exist in #{@response.body}"
# doc is returned.
def with_relation(id, ver = nil)
if ver.nil?
- get :read, :params => { :id => id }
+ get :show, :params => { :id => id }
else
with_controller(OldRelationsController.new) do
get :version, :params => { :id => id, :version => ver }
version = @response.body.to_i
# now get the new version
- get :read, :params => { :id => rel_id }
+ get :show, :params => { :id => rel_id }
assert_response :success
new_rel = xml_parse(@response.body)
end
# now get the new version
- get :read, :params => { :id => rel_id }
+ get :show, :params => { :id => rel_id }
assert_response :success
new_rel = xml_parse(@response.body)