can [:trackpoints, :map, :changes, :capabilities, :permissions], :api
can [:relation, :relation_history, :way, :way_history, :node, :node_history,
:changeset, :note, :new_note, :query], :browse
- can [:index, :feed, :read, :download, :query], Changeset
+ can [:index, :feed, :show, :download, :query], Changeset
can :index, ChangesetComment
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :preview, :copyright, :key, :id], :site
can [:index, :show, :data, :georss, :picture, :icon], Trace
can [:terms, :api_users, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :api_read, :auth_success, :auth_failure], User
can [:index, :show, :blocks_on, :blocks_by], UserBlock
- can [:read, :nodes], Node
- can [:read, :full, :ways, :ways_for_node], Way
- can [:read, :full, :relations, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
+ can [:index, :show], Node
+ can [:index, :show, :full, :ways_for_node], Way
+ can [:index, :show, :full, :relations_for_node, :relations_for_way, :relations_for_relation], Relation
can [:history, :version], OldNode
can [:history, :version], OldWay
can [:history, :version], OldRelation
##
# Return XML giving the basic info about the changeset. Does not
# return anything about the nodes, ways and relations in the changeset.
- def read
+ def show
changeset = Changeset.find(params[:id])
render :xml => changeset.to_xml(params[:include_discussion].presence).to_s
end
# Dump the details on a node given in params[:id]
- def read
+ def show
node = Node.find(params[:id])
response.last_modified = node.timestamp
end
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
- def nodes
+ def index
raise OSM::APIBadUserInput, "The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]" unless params["nodes"]
ids = params["nodes"].split(",").collect(&:to_i)
render :plain => relation.id.to_s
end
- def read
+ def show
relation = Relation.find(params[:id])
response.last_modified = relation.timestamp
if relation.visible
end
end
- def relations
+ def index
raise OSM::APIBadUserInput, "The parameter relations is required, and must be of the form relations=id[,id[,id...]]" unless params["relations"]
ids = params["relations"].split(",").collect(&:to_i)
render :plain => way.id.to_s
end
- def read
+ def show
way = Way.find(params[:id])
response.last_modified = way.timestamp
end
end
- def ways
+ def index
unless params["ways"]
raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]"
end
<% end %>
<div class='secondary-actions'>
- <%= link_to(t('.changesetxml'), :controller => "changesets", :action => "read") %>
+ <%= link_to(t('.changesetxml'), :controller => "changesets", :action => "show") %>
·
<%= link_to(t('.osmchangexml'), :controller => "changesets", :action => "download") %>
</div>
<%= render :partial => @type, :object => @feature %>
<div class='secondary-actions'>
- <%= link_to(t('browse.download_xml'), :controller => @type.pluralize, :action => "read") %>
+ <%= link_to(t('browse.download_xml'), :controller => @type.pluralize, :action => :show) %>
·
<%= link_to(t('browse.view_history'), :action => "#{@type}_history") %>
</div>
@edits.each do |changeset|
feed.entry(changeset, :updated => changeset.closed_at, :id => changeset_url(changeset.id, :only_path => false)) do |entry|
entry.link :rel => "alternate",
- :href => changeset_read_url(changeset, :only_path => false),
+ :href => changeset_show_url(changeset, :only_path => false),
:type => "application/osm+xml"
entry.link :rel => "alternate",
:href => changeset_download_url(changeset, :only_path => false),
post "changeset/:id/upload" => "changesets#upload", :id => /\d+/
get "changeset/:id/download" => "changesets#download", :as => :changeset_download, :id => /\d+/
post "changeset/:id/expand_bbox" => "changesets#expand_bbox", :id => /\d+/
- get "changeset/:id" => "changesets#read", :as => :changeset_read, :id => /\d+/
+ get "changeset/:id" => "changesets#show", :as => :changeset_show, :id => /\d+/
post "changeset/:id/subscribe" => "changesets#subscribe", :as => :changeset_subscribe, :id => /\d+/
post "changeset/:id/unsubscribe" => "changesets#unsubscribe", :as => :changeset_unsubscribe, :id => /\d+/
put "changeset/:id" => "changesets#update", :id => /\d+/
get "node/:id/history" => "old_nodes#history", :id => /\d+/
post "node/:id/:version/redact" => "old_nodes#redact", :version => /\d+/, :id => /\d+/
get "node/:id/:version" => "old_nodes#version", :id => /\d+/, :version => /\d+/
- get "node/:id" => "nodes#read", :id => /\d+/
+ get "node/:id" => "nodes#show", :id => /\d+/
put "node/:id" => "nodes#update", :id => /\d+/
delete "node/:id" => "nodes#delete", :id => /\d+/
- get "nodes" => "nodes#nodes"
+ get "nodes" => "nodes#index"
put "way/create" => "ways#create"
get "way/:id/history" => "old_ways#history", :id => /\d+/
get "way/:id/relations" => "relations#relations_for_way", :id => /\d+/
post "way/:id/:version/redact" => "old_ways#redact", :version => /\d+/, :id => /\d+/
get "way/:id/:version" => "old_ways#version", :id => /\d+/, :version => /\d+/
- get "way/:id" => "ways#read", :id => /\d+/
+ get "way/:id" => "ways#show", :id => /\d+/
put "way/:id" => "ways#update", :id => /\d+/
delete "way/:id" => "ways#delete", :id => /\d+/
- get "ways" => "ways#ways"
+ get "ways" => "ways#index"
put "relation/create" => "relations#create"
get "relation/:id/relations" => "relations#relations_for_relation", :id => /\d+/
get "relation/:id/full" => "relations#full", :id => /\d+/
post "relation/:id/:version/redact" => "old_relations#redact", :version => /\d+/, :id => /\d+/
get "relation/:id/:version" => "old_relations#version", :id => /\d+/, :version => /\d+/
- get "relation/:id" => "relations#read", :id => /\d+/
+ get "relation/:id" => "relations#show", :id => /\d+/
put "relation/:id" => "relations#update", :id => /\d+/
delete "relation/:id" => "relations#delete", :id => /\d+/
- get "relations" => "relations#relations"
+ get "relations" => "relations#index"
get "map" => "api#map"
)
assert_routing(
{ :path => "/api/0.6/changeset/1", :method => :get },
- { :controller => "changesets", :action => "read", :id => "1" }
+ { :controller => "changesets", :action => "show", :id => "1" }
)
assert_routing(
{ :path => "/api/0.6/changeset/1/subscribe", :method => :post },
end
##
- # check that the changeset can be read and returns the correct
+ # check that the changeset can be shown and returns the correct
# document structure.
- def test_read
+ def test_show
changeset_id = create(:changeset).id
- get :read, :params => { :id => changeset_id }
+ get :show, :params => { :id => changeset_id }
assert_response :success, "cannot get first changeset"
assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
assert_select "osm>changeset[id='#{changeset_id}']", 1
assert_select "osm>changeset>discussion", 0
- get :read, :params => { :id => changeset_id, :include_discussion => true }
+ get :show, :params => { :id => changeset_id, :include_discussion => true }
assert_response :success, "cannot get first changeset with comments"
assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
changeset_id = create(:changeset, :closed).id
create_list(:changeset_comment, 3, :changeset_id => changeset_id)
- get :read, :params => { :id => changeset_id, :include_discussion => true }
+ get :show, :params => { :id => changeset_id, :include_discussion => true }
assert_response :success, "cannot get closed changeset with comments"
assert_select "osm[version='#{API_VERSION}'][generator='OpenStreetMap server']", 1
##
# check that a changeset that doesn't exist returns an appropriate message
- def test_read_not_found
+ def test_show_not_found
[0, -32, 233455644, "afg", "213"].each do |id|
begin
- get :read, :params => { :id => id }
+ get :show, :params => { :id => id }
assert_response :not_found, "should get a not found"
rescue ActionController::UrlGenerationError => ex
assert_match(/No route matches/, ex.to_s)
end
# get the bounding box back from the changeset
- get :read, :params => { :id => changeset_id }
+ get :show, :params => { :id => changeset_id }
assert_response :success, "Couldn't read back changeset."
assert_select "osm>changeset[min_lon='1.0000000']", 1
assert_select "osm>changeset[max_lon='1.0000000']", 1
end
# get the bounding box back from the changeset
- get :read, :params => { :id => changeset_id }
+ get :show, :params => { :id => changeset_id }
assert_response :success, "Couldn't read back changeset for the second time."
assert_select "osm>changeset[min_lon='1.0000000']", 1
assert_select "osm>changeset[max_lon='2.0000000']", 1
end
# get the bounding box back from the changeset
- get :read, :params => { :id => changeset_id }
+ get :show, :params => { :id => changeset_id }
assert_response :success, "Couldn't read back changeset for the third time."
assert_select "osm>changeset[min_lon='1.0000000']", 1
assert_select "osm>changeset[max_lon='3.0000000']", 1
assert_response :success, "can't create a new node"
node_id = @response.body.to_i
- get :read, :params => { :id => node_id }
+ get :show, :params => { :id => node_id }
assert_response :success, "can't read back new node"
node_doc = XML::Parser.string(@response.body).parse
node_xml = node_doc.find("//osm/node").first
)
assert_routing(
{ :path => "/api/0.6/node/1", :method => :get },
- { :controller => "nodes", :action => "read", :id => "1" }
+ { :controller => "nodes", :action => "show", :id => "1" }
)
assert_routing(
{ :path => "/api/0.6/node/1", :method => :put },
)
assert_routing(
{ :path => "/api/0.6/nodes", :method => :get },
- { :controller => "nodes", :action => "nodes" }
+ { :controller => "nodes", :action => "index" }
)
end
assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x' * 256}\")"], @response.body.split(/[0-9]+,foo:/)
end
- def test_read
+ def test_show
# check that a visible node is returned properly
- get :read, :params => { :id => create(:node).id }
+ get :show, :params => { :id => create(:node).id }
assert_response :success
# check that an deleted node is not returned
- get :read, :params => { :id => create(:node, :deleted).id }
+ get :show, :params => { :id => create(:node, :deleted).id }
assert_response :gone
# check chat a non-existent node is not returned
- get :read, :params => { :id => 0 }
+ get :show, :params => { :id => 0 }
assert_response :not_found
end
##
# test fetching multiple nodes
- def test_nodes
+ def test_index
node1 = create(:node)
node2 = create(:node, :deleted)
node3 = create(:node)
node5 = create(:node, :deleted, :with_history, :version => 2)
# check error when no parameter provided
- get :nodes
+ get :index
assert_response :bad_request
# check error when no parameter value provided
- get :nodes, :params => { :nodes => "" }
+ get :index, :params => { :nodes => "" }
assert_response :bad_request
# test a working call
- get :nodes, :params => { :nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}" }
+ get :index, :params => { :nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id}" }
assert_response :success
assert_select "osm" do
assert_select "node", :count => 5
end
# check error when a non-existent node is included
- get :nodes, :params => { :nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0" }
+ get :index, :params => { :nodes => "#{node1.id},#{node2.id},#{node3.id},#{node4.id},#{node5.id},0" }
assert_response :not_found
end
assert_not_nil checknode, "node not found in data base after upload"
# and grab it using the api
- get :read, :params => { :id => nodeid }
+ get :show, :params => { :id => nodeid }
assert_response :success
apinode = Node.from_xml(@response.body)
assert_not_nil apinode, "downloaded node is nil, but shouldn't be"
def check_current_version(node_id)
# get the current version of the node
current_node = with_controller(NodesController.new) do
- get :read, :params => { :id => node_id }
+ get :show, :params => { :id => node_id }
assert_response :success, "cant get current node #{node_id}"
Node.from_xml(@response.body)
end
def check_current_version(relation_id)
# get the current version
current_relation = with_controller(RelationsController.new) do
- get :read, :params => { :id => relation_id }
+ get :show, :params => { :id => relation_id }
assert_response :success, "can't get current relation #{relation_id}"
Relation.from_xml(@response.body)
end
def check_current_version(way_id)
# get the current version
current_way = with_controller(WaysController.new) do
- get :read, :params => { :id => way_id }
+ get :show, :params => { :id => way_id }
assert_response :success, "can't get current way #{way_id}"
Way.from_xml(@response.body)
end
)
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)
)
assert_routing(
{ :path => "/api/0.6/way/1", :method => :get },
- { :controller => "ways", :action => "read", :id => "1" }
+ { :controller => "ways", :action => "show", :id => "1" }
)
assert_routing(
{ :path => "/api/0.6/way/1", :method => :put },
)
assert_routing(
{ :path => "/api/0.6/ways", :method => :get },
- { :controller => "ways", :action => "ways" }
+ { :controller => "ways", :action => "index" }
)
end
# -------------------------------------
- # Test reading ways.
+ # Test showing ways.
# -------------------------------------
- def test_read
+ def test_show
# check that a visible way is returned properly
- get :read, :params => { :id => create(:way).id }
+ get :show, :params => { :id => create(:way).id }
assert_response :success
# check that an invisible way is not returned
- get :read, :params => { :id => create(:way, :deleted).id }
+ get :show, :params => { :id => create(:way, :deleted).id }
assert_response :gone
# check chat a non-existent way is not returned
- get :read, :params => { :id => 0 }
+ get :show, :params => { :id => 0 }
assert_response :not_found
end
##
# test fetching multiple ways
- def test_ways
+ def test_index
way1 = create(:way)
way2 = create(:way, :deleted)
way3 = create(:way)
way4 = create(:way)
# check error when no parameter provided
- get :ways
+ get :index
assert_response :bad_request
# check error when no parameter value provided
- get :ways, :params => { :ways => "" }
+ get :index, :params => { :ways => "" }
assert_response :bad_request
# test a working call
- get :ways, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}" }
+ get :index, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}" }
assert_response :success
assert_select "osm" do
assert_select "way", :count => 4
end
# check error when a non-existent way is included
- get :ways, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0" }
+ get :index, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0" }
assert_response :not_found
end