Declare api way relations as nested resources
This commit is contained in:
parent
a6e614e44e
commit
2a38dca0b7
10 changed files with 108 additions and 44 deletions
|
@ -42,18 +42,10 @@ module Api
|
|||
{ :controller => "api/relations", :action => "destroy", :id => "1" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1/relations", :method => :get },
|
||||
{ :controller => "api/relations", :action => "relations_for_way", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1/relations", :method => :get },
|
||||
{ :controller => "api/relations", :action => "relations_for_relation", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/way/1/relations.json", :method => :get },
|
||||
{ :controller => "api/relations", :action => "relations_for_way", :id => "1", :format => "json" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/relation/1/relations.json", :method => :get },
|
||||
{ :controller => "api/relations", :action => "relations_for_relation", :id => "1", :format => "json" }
|
||||
|
@ -220,26 +212,6 @@ module Api
|
|||
assert_equal node.id, js_nodes[0]["id"]
|
||||
end
|
||||
|
||||
def test_relations_for_way
|
||||
way = create(:way)
|
||||
# should include relations with that way as a member
|
||||
relation_with_way = create(:relation_member, :member => way).relation
|
||||
# should ignore relations without that way as a member
|
||||
_relation_without_way = create(:relation_member).relation
|
||||
# should ignore relations with the way involved indirectly, via a relation
|
||||
second_relation = create(:relation_member, :member => way).relation
|
||||
_super_relation = create(:relation_member, :member => second_relation).relation
|
||||
# should combine multiple relation_member references into just one relation entry
|
||||
create(:relation_member, :member => way, :relation => relation_with_way)
|
||||
# should not include deleted relations
|
||||
deleted_relation = create(:relation, :deleted)
|
||||
create(:relation_member, :member => way, :relation => deleted_relation)
|
||||
|
||||
check_relations_for_element(way_relations_path(way), "way",
|
||||
way.id,
|
||||
[relation_with_way, second_relation])
|
||||
end
|
||||
|
||||
def test_relations_for_relation
|
||||
relation = create(:relation)
|
||||
# should include relations with that relation as a member
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue