From 8a2df0e0b5347be90543dc7c9f025ef8136b08c3 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 16 Jan 2019 13:10:11 +0100 Subject: [PATCH] More resourceful routing for nodes, ways, relations and changesets controllers --- app/abilities/ability.rb | 8 +-- app/controllers/changesets_controller.rb | 2 +- app/controllers/nodes_controller.rb | 4 +- app/controllers/relations_controller.rb | 4 +- app/controllers/ways_controller.rb | 4 +- app/views/browse/changeset.html.erb | 2 +- app/views/browse/feature.html.erb | 2 +- app/views/changesets/index.atom.builder | 2 +- config/routes.rb | 14 +++--- .../controllers/changesets_controller_test.rb | 24 ++++----- test/controllers/nodes_controller_test.rb | 24 ++++----- test/controllers/old_nodes_controller_test.rb | 2 +- .../old_relations_controller_test.rb | 2 +- test/controllers/old_ways_controller_test.rb | 2 +- test/controllers/relations_controller_test.rb | 50 +++++++++---------- test/controllers/ways_controller_test.rb | 24 ++++----- 16 files changed, 85 insertions(+), 85 deletions(-) diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 90f377931..c4cca7cc5 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -7,7 +7,7 @@ class Ability 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 @@ -23,9 +23,9 @@ class Ability 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 diff --git a/app/controllers/changesets_controller.rb b/app/controllers/changesets_controller.rb index 97ff85f02..80b8aff48 100644 --- a/app/controllers/changesets_controller.rb +++ b/app/controllers/changesets_controller.rb @@ -42,7 +42,7 @@ class ChangesetsController < ApplicationController ## # 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 diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 65f9b27ed..6c1d66db4 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -26,7 +26,7 @@ class NodesController < ApplicationController 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 @@ -63,7 +63,7 @@ class NodesController < ApplicationController 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) diff --git a/app/controllers/relations_controller.rb b/app/controllers/relations_controller.rb index 27bf5cdf8..8c8005acc 100644 --- a/app/controllers/relations_controller.rb +++ b/app/controllers/relations_controller.rb @@ -22,7 +22,7 @@ class RelationsController < ApplicationController render :plain => relation.id.to_s end - def read + def show relation = Relation.find(params[:id]) response.last_modified = relation.timestamp if relation.visible @@ -123,7 +123,7 @@ class RelationsController < ApplicationController 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) diff --git a/app/controllers/ways_controller.rb b/app/controllers/ways_controller.rb index 85d9b5a5b..caf787105 100644 --- a/app/controllers/ways_controller.rb +++ b/app/controllers/ways_controller.rb @@ -22,7 +22,7 @@ class WaysController < ApplicationController render :plain => way.id.to_s end - def read + def show way = Way.find(params[:id]) response.last_modified = way.timestamp @@ -82,7 +82,7 @@ class WaysController < ApplicationController 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 diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb index c63b0112e..0b73fa083 100644 --- a/app/views/browse/changeset.html.erb +++ b/app/views/browse/changeset.html.erb @@ -137,7 +137,7 @@ <% end %>
- <%= link_to(t('.changesetxml'), :controller => "changesets", :action => "read") %> + <%= link_to(t('.changesetxml'), :controller => "changesets", :action => "show") %> · <%= link_to(t('.osmchangexml'), :controller => "changesets", :action => "download") %>
diff --git a/app/views/browse/feature.html.erb b/app/views/browse/feature.html.erb index c3fadbe31..5674f21b0 100644 --- a/app/views/browse/feature.html.erb +++ b/app/views/browse/feature.html.erb @@ -8,7 +8,7 @@ <%= render :partial => @type, :object => @feature %>
- <%= 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") %>
diff --git a/app/views/changesets/index.atom.builder b/app/views/changesets/index.atom.builder index 57befe117..05d9ab68a 100644 --- a/app/views/changesets/index.atom.builder +++ b/app/views/changesets/index.atom.builder @@ -17,7 +17,7 @@ atom_feed(:language => I18n.locale, :schema_date => 2009, @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), diff --git a/config/routes.rb b/config/routes.rb index b245e8fec..b0fe5e48e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,7 +10,7 @@ OpenStreetMap::Application.routes.draw do 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+/ @@ -26,10 +26,10 @@ OpenStreetMap::Application.routes.draw do 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+/ @@ -37,10 +37,10 @@ OpenStreetMap::Application.routes.draw do 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+/ @@ -48,10 +48,10 @@ OpenStreetMap::Application.routes.draw do 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" diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index 35ee9c469..a3c8947ca 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -22,7 +22,7 @@ class ChangesetsControllerTest < ActionController::TestCase ) 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 }, @@ -152,19 +152,19 @@ class ChangesetsControllerTest < ActionController::TestCase 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 @@ -175,7 +175,7 @@ class ChangesetsControllerTest < ActionController::TestCase 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 @@ -186,10 +186,10 @@ class ChangesetsControllerTest < ActionController::TestCase ## # 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) @@ -1483,7 +1483,7 @@ CHANGESET 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 @@ -1498,7 +1498,7 @@ CHANGESET 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 @@ -1513,7 +1513,7 @@ CHANGESET 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 @@ -1789,7 +1789,7 @@ CHANGESET 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 diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 77a6d372b..e63f04e11 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -10,7 +10,7 @@ class NodesControllerTest < ActionController::TestCase ) 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 }, @@ -22,7 +22,7 @@ class NodesControllerTest < ActionController::TestCase ) assert_routing( { :path => "/api/0.6/nodes", :method => :get }, - { :controller => "nodes", :action => "nodes" } + { :controller => "nodes", :action => "index" } ) end @@ -132,17 +132,17 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -427,7 +427,7 @@ class NodesControllerTest < ActionController::TestCase ## # test fetching multiple nodes - def test_nodes + def test_index node1 = create(:node) node2 = create(:node, :deleted) node3 = create(:node) @@ -435,15 +435,15 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -455,7 +455,7 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -518,7 +518,7 @@ class NodesControllerTest < ActionController::TestCase 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" diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index 53c507234..94d16c8c0 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -386,7 +386,7 @@ class OldNodesControllerTest < ActionController::TestCase 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 diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index 51e6c565a..9dd9a7165 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -225,7 +225,7 @@ class OldRelationsControllerTest < ActionController::TestCase 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 diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index 0dd2d5e3c..737ca1faf 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -265,7 +265,7 @@ class OldWaysControllerTest < ActionController::TestCase 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 diff --git a/test/controllers/relations_controller_test.rb b/test/controllers/relations_controller_test.rb index fe35637bd..a8b0ed2df 100644 --- a/test/controllers/relations_controller_test.rb +++ b/test/controllers/relations_controller_test.rb @@ -14,7 +14,7 @@ class RelationsControllerTest < ActionController::TestCase ) 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 }, @@ -26,7 +26,7 @@ class RelationsControllerTest < ActionController::TestCase ) assert_routing( { :path => "/api/0.6/relations", :method => :get }, - { :controller => "relations", :action => "relations" } + { :controller => "relations", :action => "index" } ) assert_routing( @@ -44,20 +44,20 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -160,7 +160,7 @@ class RelationsControllerTest < ActionController::TestCase ## # test fetching multiple relations - def test_relations + def test_index relation1 = create(:relation) relation2 = create(:relation, :deleted) relation3 = create(:relation, :with_history, :version => 2) @@ -168,15 +168,15 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -187,7 +187,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -270,7 +270,7 @@ class RelationsControllerTest < ActionController::TestCase 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 ### @@ -301,7 +301,7 @@ class RelationsControllerTest < ActionController::TestCase "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 ### @@ -331,7 +331,7 @@ class RelationsControllerTest < ActionController::TestCase "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 ### @@ -361,7 +361,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -690,7 +690,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -753,7 +753,7 @@ OSM 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) @@ -773,7 +773,7 @@ OSM 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) @@ -820,7 +820,7 @@ OSM 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 @@ -853,7 +853,7 @@ OSM 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) @@ -952,7 +952,7 @@ OSM # 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}" @@ -969,7 +969,7 @@ OSM # 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 } @@ -990,7 +990,7 @@ OSM 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) @@ -1022,7 +1022,7 @@ OSM 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) diff --git a/test/controllers/ways_controller_test.rb b/test/controllers/ways_controller_test.rb index 091ce18c4..3c141dce0 100644 --- a/test/controllers/ways_controller_test.rb +++ b/test/controllers/ways_controller_test.rb @@ -14,7 +14,7 @@ class WaysControllerTest < ActionController::TestCase ) 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 }, @@ -26,25 +26,25 @@ class WaysControllerTest < ActionController::TestCase ) 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 @@ -78,22 +78,22 @@ class WaysControllerTest < ActionController::TestCase ## # 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 @@ -104,7 +104,7 @@ class WaysControllerTest < ActionController::TestCase 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 -- 2.43.2