3 class SearchControllerTest < ActionController::TestCase
7 # test all routes which lead to this controller
10 { :path => "/api/0.6/search", :method => :get },
11 { :controller => "search", :action => "search_all" }
14 { :path => "/api/0.6/nodes/search", :method => :get },
15 { :controller => "search", :action => "search_nodes" }
18 { :path => "/api/0.6/ways/search", :method => :get },
19 { :controller => "search", :action => "search_ways" }
22 { :path => "/api/0.6/relations/search", :method => :get },
23 { :controller => "search", :action => "search_relations" }
28 # test searching nodes
30 get :search_nodes, :type => "test"
31 assert_response :service_unavailable
32 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
34 get :search_nodes, :type => "test", :value => "yes"
35 assert_response :service_unavailable
36 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
38 get :search_nodes, :name => "Test Node"
39 assert_response :service_unavailable
40 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
46 [:visible_way, :invisible_way, :used_way].each do |way|
47 create(:way_tag, :way => current_ways(way), :k => "test", :v => "yes")
49 create(:way_tag, :way => current_ways(:used_way), :k => "name", :v => "Test Way")
51 get :search_ways, :type => "test"
52 assert_response :service_unavailable
53 assert_equal "Searching for a key without value is currently unavailable", response.headers["Error"]
55 get :search_ways, :type => "test", :value => "yes"
56 assert_response :success
57 assert_select "way", 3
59 get :search_ways, :name => "Test Way"
60 assert_response :success
61 assert_select "way", 1
65 # test searching relations
66 def test_search_relations
67 get :search_relations, :type => "test"
68 assert_response :service_unavailable
69 assert_equal "Searching for a key without value is currently unavailable", response.headers["Error"]
71 get :search_relations, :type => "test", :value => "yes"
72 assert_response :success
73 assert_select "relation", 3
75 get :search_relations, :name => "Test Relation"
76 assert_response :success
77 assert_select "relation", 1
81 # test searching nodes, ways and relations
83 get :search_all, :type => "test"
84 assert_response :service_unavailable
85 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
87 get :search_all, :type => "test", :value => "yes"
88 assert_response :service_unavailable
89 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]
91 get :search_all, :name => "Test"
92 assert_response :service_unavailable
93 assert_equal "Searching of nodes is currently unavailable", response.headers["Error"]