get "node/:id" => "nodes#show", :as => :api_node, :id => /\d+/
put "node/:id" => "nodes#update", :id => /\d+/
delete "node/:id" => "nodes#delete", :id => /\d+/
- get "nodes" => "nodes#index"
put "way/create" => "ways#create"
get "way/:id/history" => "old_ways#history", :as => :api_way_history, :id => /\d+/
get "way/:id" => "ways#show", :as => :api_way, :id => /\d+/
put "way/:id" => "ways#update", :id => /\d+/
delete "way/:id" => "ways#delete", :id => /\d+/
- get "ways" => "ways#index"
put "relation/create" => "relations#create"
get "relation/:id/relations" => "relations#relations_for_relation", :as => :relation_relations, :id => /\d+/
get "relation/:id" => "relations#show", :as => :api_relation, :id => /\d+/
put "relation/:id" => "relations#update", :id => /\d+/
delete "relation/:id" => "relations#delete", :id => /\d+/
- get "relations" => "relations#index"
end
namespace :api, :path => "api/0.6" do
+ resources :nodes, :only => :index
+ resources :ways, :only => :index
+ resources :relations, :only => :index
+
resource :map, :only => :show
resources :tracepoints, :path => "trackpoints", :only => :index
node5 = create(:node, :deleted, :with_history, :version => 2)
# check error when no parameter provided
- get nodes_path
+ get api_nodes_path
assert_response :bad_request
# check error when no parameter value provided
- get nodes_path(:nodes => "")
+ get api_nodes_path(:nodes => "")
assert_response :bad_request
# test a working call
- get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}")
+ get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}")
assert_response :success
assert_select "osm" do
assert_select "node", :count => 5
end
# test a working call with json format
- get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}", :format => "json")
+ get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}", :format => "json")
js = ActiveSupport::JSON.decode(@response.body)
assert_not_nil js
assert_equal 1, (js["elements"].count { |a| a["id"] == node5.id && a["visible"] == false })
# check error when a non-existent node is included
- get nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0")
+ get api_nodes_path(:nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0")
assert_response :not_found
end
relation4.old_relations.find_by(:version => 1).redact!(create(:redaction))
# check error when no parameter provided
- get relations_path
+ get api_relations_path
assert_response :bad_request
# check error when no parameter value provided
- get relations_path(:relations => "")
+ get api_relations_path(:relations => "")
assert_response :bad_request
# test a working call
- get relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}")
+ get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}")
assert_response :success
assert_select "osm" do
assert_select "relation", :count => 4
end
# test a working call with json format
- get relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}", :format => "json")
+ get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}", :format => "json")
js = ActiveSupport::JSON.decode(@response.body)
assert_not_nil js
assert_equal 1, (js["elements"].count { |a| a["id"] == relation4.id && a["visible"].nil? })
# check error when a non-existent relation is included
- get relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id},0")
+ get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id},0")
assert_response :not_found
end
way4 = create(:way)
# check error when no parameter provided
- get ways_path
+ get api_ways_path
assert_response :bad_request
# check error when no parameter value provided
- get ways_path(:ways => "")
+ get api_ways_path(:ways => "")
assert_response :bad_request
# test a working call
- get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}")
+ get api_ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}")
assert_response :success
assert_select "osm" do
assert_select "way", :count => 4
end
# test a working call with json format
- get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}", :format => "json")
+ get api_ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}", :format => "json")
js = ActiveSupport::JSON.decode(@response.body)
assert_not_nil js
assert_equal 1, (js["elements"].count { |a| a["id"] == way4.id && a["visible"].nil? })
# check error when a non-existent way is included
- get ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0")
+ get api_ways_path(:ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0")
assert_response :not_found
end