3 class SearchControllerTest < ActionController::TestCase
5 # test all routes which lead to this controller
8 { :path => "/api/0.6/search", :method => :get },
9 { :controller => "search", :action => "search_all" }
12 { :path => "/api/0.6/nodes/search", :method => :get },
13 { :controller => "search", :action => "search_nodes" }
16 { :path => "/api/0.6/ways/search", :method => :get },
17 { :controller => "search", :action => "search_ways" }
20 { :path => "/api/0.6/relations/search", :method => :get },
21 { :controller => "search", :action => "search_relations" }
26 # test searching nodes
28 get :search_nodes, :type => "test"
29 assert_response :status => :service_unavailable
30 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
32 get :search_nodes, :type => "test", :value => "yes"
33 assert_response :status => :service_unavailable
34 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
36 get :search_nodes, :name => "Test Node"
37 assert_response :status => :service_unavailable
38 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
44 get :search_ways, :type => "test"
45 assert_response :status => :service_unavailable
46 assert_equal "Searching for a key without value is currently unavailable", response.headers["Error"]
48 get :search_ways, :type => "test", :value => "yes"
49 assert_response :status => :success
50 assert_select "way", 3
52 get :search_ways, :name => "Test Way"
53 assert_response :status => :success
54 assert_select "way", 1
58 # test searching relations
60 get :search_relations, :type => "test"
61 assert_response :status => :service_unavailable
62 assert_equal "Searching for a key without value is currently unavailable", response.headers["Error"]
64 get :search_relations, :type => "test", :value => "yes"
65 assert_response :status => :success
66 assert_select "relation", 3
68 get :search_relations, :name => "Test Relation"
69 assert_response :status => :success
70 assert_select "relation", 1
74 # test searching nodes, ways and relations
76 get :search_all, :type => "test"
77 assert_response :status => :service_unavailable
78 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
80 get :search_all, :type => "test", :value => "yes"
81 assert_response :status => :service_unavailable
82 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
84 get :search_all, :name => "Test"
85 assert_response :status => :service_unavailable
86 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]