can :index, :map
can :show, :permission
can [:search_all, :search_nodes, :search_ways, :search_relations], :search
+ can :show, :version
if Settings.status != "database_offline"
can [:show, :download, :query], Changeset
--- /dev/null
+module Api
+ class VersionsController < ApiController
+ authorize_resource :class => false
+
+ around_action :api_call_handle_error, :api_call_timeout
+
+ # Show the list of available API versions. This will replace the global
+ # unversioned capabilities call in due course.
+ # Currently we only support deploying one version at a time, but this will
+ # hopefully change soon.
+ def show
+ @versions = [Settings.api_version]
+ end
+ end
+end
--- /dev/null
+xml.instruct! :xml, :version => "1.0"
+xml.osm(OSM::API.new.xml_root_attributes.except("version")) do |osm|
+ osm.api do |api|
+ @versions.each do |version|
+ api.version version
+ end
+ end
+end
OpenStreetMap::Application.routes.draw do
# API
namespace :api do
- get "capabilities" => "capabilities#show"
+ get "capabilities" => "capabilities#show" # Deprecated, remove when 0.6 support is removed
+ get "versions" => "versions#show"
end
scope "api/0.6" do
--- /dev/null
+require "test_helper"
+
+module Api
+ class VersionsControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/versions", :method => :get },
+ { :controller => "api/versions", :action => "show" }
+ )
+ assert_recognizes(
+ { :controller => "api/versions", :action => "show" },
+ { :path => "/api/versions", :method => :get }
+ )
+ end
+
+ def test_versions
+ get :show
+ assert_response :success
+ assert_select "osm[generator='#{Settings.generator}']", :count => 1 do
+ assert_select "api", :count => 1 do
+ assert_select "version", Settings.api_version
+ end
+ end
+ end
+
+ def test_no_version_in_root_element
+ get :show
+ assert_response :success
+ assert_select "osm[version]", :count => 0
+ end
+ end
+end