4 class CapabilitiesControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/capabilities", :method => :get },
10 { :controller => "api/capabilities", :action => "show" }
13 { :path => "/api/capabilities.json", :method => :get },
14 { :controller => "api/capabilities", :action => "show", :format => "json" }
17 { :controller => "api/capabilities", :action => "show" },
18 { :path => "/api/0.6/capabilities", :method => :get }
21 { :controller => "api/capabilities", :action => "show", :format => "json" },
22 { :path => "/api/0.6/capabilities.json", :method => :get }
27 get api_capabilities_path
28 assert_response :success
29 assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
30 assert_select "api", :count => 1 do
31 assert_select "version[minimum='#{Settings.api_version}'][maximum='#{Settings.api_version}']", :count => 1
32 assert_select "area[maximum='#{Settings.max_request_area}']", :count => 1
33 assert_select "note_area[maximum='#{Settings.max_note_request_area}']", :count => 1
34 assert_select "tracepoints[per_page='#{Settings.tracepoints_per_page}']", :count => 1
35 assert_select "changesets[maximum_elements='#{Changeset::MAX_ELEMENTS}']", :count => 1
36 assert_select "relationmembers[maximum='#{Settings.max_number_of_relation_members}']", :count => 1
37 assert_select "status[database='online']", :count => 1
38 assert_select "status[api='online']", :count => 1
39 assert_select "status[gpx='online']", :count => 1
44 def test_capabilities_json
45 get api_capabilities_path, :params => { :format => "json" }
46 assert_response :success
47 js = ActiveSupport::JSON.decode(@response.body)
50 assert_equal Settings.api_version, js["version"]
51 assert_equal Settings.generator, js["generator"]
52 assert_equal Settings.api_version, js["api"]["version"]["minimum"]
53 assert_equal Settings.api_version, js["api"]["version"]["maximum"]
54 assert_equal Settings.max_request_area, js["api"]["area"]["maximum"]
55 assert_equal Settings.max_note_request_area, js["api"]["note_area"]["maximum"]
56 assert_equal Settings.tracepoints_per_page, js["api"]["tracepoints"]["per_page"]
57 assert_equal Changeset::MAX_ELEMENTS, js["api"]["changesets"]["maximum_elements"]
58 assert_equal Settings.default_changeset_query_limit, js["api"]["changesets"]["default_query_limit"]
59 assert_equal Settings.max_changeset_query_limit, js["api"]["changesets"]["maximum_query_limit"]
60 assert_equal Settings.max_number_of_relation_members, js["api"]["relationmembers"]["maximum"]
61 assert_equal "online", js["api"]["status"]["database"]
62 assert_equal "online", js["api"]["status"]["api"]
63 assert_equal "online", js["api"]["status"]["gpx"]
64 assert_equal Settings.imagery_blacklist.length, js["policy"]["imagery"]["blacklist"].length