1 require File.dirname(__FILE__) + '/../test_helper'
3 class NotesControllerTest < ActionController::TestCase
4 fixtures :users, :notes, :note_comments
7 # test all routes which lead to this controller
10 { :path => "/api/0.6/notes", :method => :post },
11 { :controller => "notes", :action => "create", :format => "xml" }
14 { :path => "/api/0.6/notes/1", :method => :get },
15 { :controller => "notes", :action => "show", :id => "1", :format => "xml" }
18 { :controller => "notes", :action => "show", :id => "1", :format => "xml" },
19 { :path => "/api/0.6/notes/1.xml", :method => :get }
22 { :path => "/api/0.6/notes/1.rss", :method => :get },
23 { :controller => "notes", :action => "show", :id => "1", :format => "rss" }
26 { :path => "/api/0.6/notes/1.json", :method => :get },
27 { :controller => "notes", :action => "show", :id => "1", :format => "json" }
30 { :path => "/api/0.6/notes/1.gpx", :method => :get },
31 { :controller => "notes", :action => "show", :id => "1", :format => "gpx" }
34 { :path => "/api/0.6/notes/1/comment", :method => :post },
35 { :controller => "notes", :action => "comment", :id => "1", :format => "xml" }
38 { :path => "/api/0.6/notes/1/close", :method => :post },
39 { :controller => "notes", :action => "close", :id => "1", :format => "xml" }
42 { :path => "/api/0.6/notes/1/reopen", :method => :post },
43 { :controller => "notes", :action => "reopen", :id => "1", :format => "xml" }
46 { :path => "/api/0.6/notes/1", :method => :delete },
47 { :controller => "notes", :action => "destroy", :id => "1", :format => "xml" }
51 { :path => "/api/0.6/notes", :method => :get },
52 { :controller => "notes", :action => "index", :format => "xml" }
55 { :controller => "notes", :action => "index", :format => "xml" },
56 { :path => "/api/0.6/notes.xml", :method => :get }
59 { :path => "/api/0.6/notes.rss", :method => :get },
60 { :controller => "notes", :action => "index", :format => "rss" }
63 { :path => "/api/0.6/notes.json", :method => :get },
64 { :controller => "notes", :action => "index", :format => "json" }
67 { :path => "/api/0.6/notes.gpx", :method => :get },
68 { :controller => "notes", :action => "index", :format => "gpx" }
72 { :path => "/api/0.6/notes/search", :method => :get },
73 { :controller => "notes", :action => "search", :format => "xml" }
76 { :controller => "notes", :action => "search", :format => "xml" },
77 { :path => "/api/0.6/notes/search.xml", :method => :get }
80 { :path => "/api/0.6/notes/search.rss", :method => :get },
81 { :controller => "notes", :action => "search", :format => "rss" }
84 { :path => "/api/0.6/notes/search.json", :method => :get },
85 { :controller => "notes", :action => "search", :format => "json" }
88 { :path => "/api/0.6/notes/search.gpx", :method => :get },
89 { :controller => "notes", :action => "search", :format => "gpx" }
93 { :path => "/api/0.6/notes/feed", :method => :get },
94 { :controller => "notes", :action => "feed", :format => "rss" }
98 { :controller => "notes", :action => "create" },
99 { :path => "/api/0.6/notes/addPOIexec", :method => :post }
102 { :controller => "notes", :action => "close" },
103 { :path => "/api/0.6/notes/closePOIexec", :method => :post }
106 { :controller => "notes", :action => "comment" },
107 { :path => "/api/0.6/notes/editPOIexec", :method => :post }
110 { :controller => "notes", :action => "index", :format => "gpx" },
111 { :path => "/api/0.6/notes/getGPX", :method => :get }
114 { :controller => "notes", :action => "feed", :format => "rss" },
115 { :path => "/api/0.6/notes/getRSSfeed", :method => :get }
119 { :path => "/user/username/notes", :method => :get },
120 { :controller => "notes", :action => "mine", :display_name => "username" }
124 def test_create_success
125 assert_difference('Note.count') do
126 assert_difference('NoteComment.count') do
127 post :create, {:lat => -1.0, :lon => -1.0, :text => "This is a comment", :format => "json"}
130 assert_response :success
131 js = ActiveSupport::JSON.decode(@response.body)
133 assert_equal "Feature", js["type"]
134 assert_equal "Point", js["geometry"]["type"]
135 assert_equal [-1.0, -1.0], js["geometry"]["coordinates"]
136 assert_equal "open", js["properties"]["status"]
137 assert_equal 1, js["properties"]["comments"].count
138 assert_equal "opened", js["properties"]["comments"].last["action"]
139 assert_equal "This is a comment", js["properties"]["comments"].last["text"]
140 assert_nil js["properties"]["comments"].last["user"]
141 id = js["properties"]["id"]
143 get :show, {:id => id, :format => "json"}
144 assert_response :success
145 js = ActiveSupport::JSON.decode(@response.body)
147 assert_equal "Feature", js["type"]
148 assert_equal "Point", js["geometry"]["type"]
149 assert_equal [-1.0, -1.0], js["geometry"]["coordinates"]
150 assert_equal id, js["properties"]["id"]
151 assert_equal "open", js["properties"]["status"]
152 assert_equal 1, js["properties"]["comments"].count
153 assert_equal "opened", js["properties"]["comments"].last["action"]
154 assert_equal "This is a comment", js["properties"]["comments"].last["text"]
155 assert_nil js["properties"]["comments"].last["user"]
159 assert_no_difference('Note.count') do
160 assert_no_difference('NoteComment.count') do
161 post :create, {:lon => -1.0, :text => "This is a comment"}
164 assert_response :bad_request
166 assert_no_difference('Note.count') do
167 assert_no_difference('NoteComment.count') do
168 post :create, {:lat => -1.0, :text => "This is a comment"}
171 assert_response :bad_request
173 assert_no_difference('Note.count') do
174 assert_no_difference('NoteComment.count') do
175 post :create, {:lat => -1.0, :lon => -1.0}
178 assert_response :bad_request
180 assert_no_difference('Note.count') do
181 assert_no_difference('NoteComment.count') do
182 post :create, {:lat => -1.0, :lon => -1.0, :text => ""}
185 assert_response :bad_request
187 assert_no_difference('Note.count') do
188 assert_no_difference('NoteComment.count') do
189 post :create, {:lat => -100.0, :lon => -1.0, :text => "This is a comment"}
192 assert_response :bad_request
194 assert_no_difference('Note.count') do
195 assert_no_difference('NoteComment.count') do
196 post :create, {:lat => -1.0, :lon => -200.0, :text => "This is a comment"}
199 assert_response :bad_request
201 assert_no_difference('Note.count') do
202 assert_no_difference('NoteComment.count') do
203 post :create, {:lat => 'abc', :lon => -1.0, :text => "This is a comment"}
206 assert_response :bad_request
208 assert_no_difference('Note.count') do
209 assert_no_difference('NoteComment.count') do
210 post :create, {:lat => -1.0, :lon => 'abc', :text => "This is a comment"}
213 assert_response :bad_request
216 def test_comment_success
217 assert_difference('NoteComment.count') do
218 post :comment, {:id => notes(:open_note_with_comment).id, :text => "This is an additional comment", :format => "json"}
220 assert_response :success
221 js = ActiveSupport::JSON.decode(@response.body)
223 assert_equal "Feature", js["type"]
224 assert_equal notes(:open_note_with_comment).id, js["properties"]["id"]
225 assert_equal "open", js["properties"]["status"]
226 assert_equal 3, js["properties"]["comments"].count
227 assert_equal "commented", js["properties"]["comments"].last["action"]
228 assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
229 assert_nil js["properties"]["comments"].last["user"]
231 get :show, {:id => notes(:open_note_with_comment).id, :format => "json"}
232 assert_response :success
233 js = ActiveSupport::JSON.decode(@response.body)
235 assert_equal "Feature", js["type"]
236 assert_equal notes(:open_note_with_comment).id, js["properties"]["id"]
237 assert_equal "open", js["properties"]["status"]
238 assert_equal 3, js["properties"]["comments"].count
239 assert_equal "commented", js["properties"]["comments"].last["action"]
240 assert_equal "This is an additional comment", js["properties"]["comments"].last["text"]
241 assert_nil js["properties"]["comments"].last["user"]
244 def test_comment_fail
245 assert_no_difference('NoteComment.count') do
246 post :comment, {:text => "This is an additional comment"}
248 assert_response :bad_request
250 assert_no_difference('NoteComment.count') do
251 post :comment, {:id => notes(:open_note_with_comment).id}
253 assert_response :bad_request
255 assert_no_difference('NoteComment.count') do
256 post :comment, {:id => notes(:open_note_with_comment).id, :text => ""}
258 assert_response :bad_request
260 assert_no_difference('NoteComment.count') do
261 post :comment, {:id => 12345, :text => "This is an additional comment"}
263 assert_response :not_found
265 assert_no_difference('NoteComment.count') do
266 post :comment, {:id => notes(:hidden_note_with_comment).id, :text => "This is an additional comment"}
268 assert_response :gone
270 assert_no_difference('NoteComment.count') do
271 post :comment, {:id => notes(:closed_note_with_comment).id, :text => "This is an additional comment"}
273 assert_response :conflict
276 def test_close_success
277 post :close, {:id => notes(:open_note_with_comment).id, :text => "This is a close comment", :format => "json"}
278 assert_response :unauthorized
280 basic_authorization(users(:public_user).email, "test")
282 post :close, {:id => notes(:open_note_with_comment).id, :text => "This is a close comment", :format => "json"}
283 assert_response :success
284 js = ActiveSupport::JSON.decode(@response.body)
286 assert_equal "Feature", js["type"]
287 assert_equal notes(:open_note_with_comment).id, js["properties"]["id"]
288 assert_equal "closed", js["properties"]["status"]
289 assert_equal 3, js["properties"]["comments"].count
290 assert_equal "closed", js["properties"]["comments"].last["action"]
291 assert_equal "This is a close comment", js["properties"]["comments"].last["text"]
292 assert_equal "test2", js["properties"]["comments"].last["user"]
294 get :show, {:id => notes(:open_note_with_comment).id, :format => "json"}
295 assert_response :success
296 js = ActiveSupport::JSON.decode(@response.body)
298 assert_equal "Feature", js["type"]
299 assert_equal notes(:open_note_with_comment).id, js["properties"]["id"]
300 assert_equal "closed", js["properties"]["status"]
301 assert_equal 3, js["properties"]["comments"].count
302 assert_equal "closed", js["properties"]["comments"].last["action"]
303 assert_equal "This is a close comment", js["properties"]["comments"].last["text"]
304 assert_equal "test2", js["properties"]["comments"].last["user"]
309 assert_response :unauthorized
311 basic_authorization(users(:public_user).email, "test")
314 assert_response :bad_request
316 post :close, {:id => 12345}
317 assert_response :not_found
319 post :close, {:id => notes(:hidden_note_with_comment).id}
320 assert_response :gone
322 post :close, {:id => notes(:closed_note_with_comment).id}
323 assert_response :conflict
326 def test_reopen_success
327 post :reopen, {:id => notes(:closed_note_with_comment).id, :text => "This is a reopen comment", :format => "json"}
328 assert_response :unauthorized
330 basic_authorization(users(:public_user).email, "test")
332 post :reopen, {:id => notes(:closed_note_with_comment).id, :text => "This is a reopen comment", :format => "json"}
333 assert_response :success
334 js = ActiveSupport::JSON.decode(@response.body)
336 assert_equal "Feature", js["type"]
337 assert_equal notes(:closed_note_with_comment).id, js["properties"]["id"]
338 assert_equal "open", js["properties"]["status"]
339 assert_equal 2, js["properties"]["comments"].count
340 assert_equal "reopened", js["properties"]["comments"].last["action"]
341 assert_equal "This is a reopen comment", js["properties"]["comments"].last["text"]
342 assert_equal "test2", js["properties"]["comments"].last["user"]
344 get :show, {:id => notes(:closed_note_with_comment).id, :format => "json"}
345 assert_response :success
346 js = ActiveSupport::JSON.decode(@response.body)
348 assert_equal "Feature", js["type"]
349 assert_equal notes(:closed_note_with_comment).id, js["properties"]["id"]
350 assert_equal "open", js["properties"]["status"]
351 assert_equal 2, js["properties"]["comments"].count
352 assert_equal "reopened", js["properties"]["comments"].last["action"]
353 assert_equal "This is a reopen comment", js["properties"]["comments"].last["text"]
354 assert_equal "test2", js["properties"]["comments"].last["user"]
358 post :reopen, {:id => notes(:hidden_note_with_comment).id}
359 assert_response :unauthorized
361 basic_authorization(users(:public_user).email, "test")
363 post :reopen, {:id => 12345}
364 assert_response :not_found
366 post :reopen, {:id => notes(:hidden_note_with_comment).id}
367 assert_response :gone
369 post :reopen, {:id => notes(:open_note_with_comment).id}
370 assert_response :conflict
373 def test_show_success
374 get :show, {:id => notes(:open_note).id, :format => "xml"}
375 assert_response :success
376 assert_equal "application/xml", @response.content_type
377 assert_select "osm", :count => 1 do
378 assert_select "note[lat=#{notes(:open_note).lat}][lon=#{notes(:open_note).lon}]", :count => 1 do
379 assert_select "id", notes(:open_note).id
380 assert_select "url", note_url(notes(:open_note), :format => "xml")
381 assert_select "comment_url", comment_note_url(notes(:open_note), :format => "xml")
382 assert_select "close_url", close_note_url(notes(:open_note), :format => "xml")
383 assert_select "date_created", notes(:open_note).created_at.to_s
384 assert_select "status", notes(:open_note).status
385 assert_select "comments", :count => 1 do
386 assert_select "comment", :count => 1
391 get :show, {:id => notes(:open_note).id, :format => "rss"}
392 assert_response :success
393 assert_equal "application/rss+xml", @response.content_type
394 assert_select "rss", :count => 1 do
395 assert_select "channel", :count => 1 do
396 assert_select "item", :count => 1 do
397 assert_select "link", browse_note_url(notes(:open_note))
398 assert_select "guid", note_url(notes(:open_note))
399 assert_select "pubDate", notes(:open_note).created_at.to_s(:rfc822)
400 # assert_select "geo:lat", notes(:open_note).lat.to_s
401 # assert_select "geo:long", notes(:open_note).lon
402 # assert_select "georss:point", "#{notes(:open_note).lon} #{notes(:open_note).lon}"
407 get :show, {:id => notes(:open_note).id, :format => "json"}
408 assert_response :success
409 assert_equal "application/json", @response.content_type
410 js = ActiveSupport::JSON.decode(@response.body)
412 assert_equal "Feature", js["type"]
413 assert_equal "Point", js["geometry"]["type"]
414 assert_equal notes(:open_note).lat, js["geometry"]["coordinates"][0]
415 assert_equal notes(:open_note).lon, js["geometry"]["coordinates"][1]
416 assert_equal notes(:open_note).id, js["properties"]["id"]
417 assert_equal note_url(notes(:open_note), :format => "json"), js["properties"]["url"]
418 assert_equal comment_note_url(notes(:open_note), :format => "json"), js["properties"]["comment_url"]
419 assert_equal close_note_url(notes(:open_note), :format => "json"), js["properties"]["close_url"]
420 assert_equal notes(:open_note).created_at, js["properties"]["date_created"]
421 assert_equal notes(:open_note).status, js["properties"]["status"]
423 get :show, {:id => notes(:open_note).id, :format => "gpx"}
424 assert_response :success
425 assert_equal "application/gpx+xml", @response.content_type
426 assert_select "gpx", :count => 1 do
427 assert_select "wpt[lat=#{notes(:open_note).lat}][lon=#{notes(:open_note).lon}]", :count => 1 do
428 assert_select "extension", :count => 1 do
429 assert_select "id", notes(:open_note).id
430 assert_select "url", note_url(notes(:open_note), :format => "gpx")
431 assert_select "comment_url", comment_note_url(notes(:open_note), :format => "gpx")
432 assert_select "close_url", close_note_url(notes(:open_note), :format => "gpx")
438 def test_show_hidden_comment
439 get :show, {:id => notes(:note_with_hidden_comment).id, :format => "json"}
440 assert_response :success
441 js = ActiveSupport::JSON.decode(@response.body)
443 assert_equal "Feature", js["type"]
444 assert_equal notes(:note_with_hidden_comment).id, js["properties"]["id"]
445 assert_equal 2, js["properties"]["comments"].count
446 assert_equal "Valid comment for note 5", js["properties"]["comments"][0]["text"]
447 assert_equal "Another valid comment for note 5", js["properties"]["comments"][1]["text"]
451 get :show, {:id => 12345}
452 assert_response :not_found
454 get :show, {:id => notes(:hidden_note_with_comment).id}
455 assert_response :gone
458 def test_destroy_success
459 delete :destroy, {:id => notes(:open_note_with_comment).id, :text => "This is a hide comment", :format => "json"}
460 assert_response :unauthorized
462 basic_authorization(users(:public_user).email, "test")
464 delete :destroy, {:id => notes(:open_note_with_comment).id, :text => "This is a hide comment", :format => "json"}
465 assert_response :forbidden
467 basic_authorization(users(:moderator_user).email, "test")
469 delete :destroy, {:id => notes(:open_note_with_comment).id, :text => "This is a hide comment", :format => "json"}
470 assert_response :success
471 js = ActiveSupport::JSON.decode(@response.body)
473 assert_equal "Feature", js["type"]
474 assert_equal notes(:open_note_with_comment).id, js["properties"]["id"]
475 assert_equal "hidden", js["properties"]["status"]
476 assert_equal 3, js["properties"]["comments"].count
477 assert_equal "hidden", js["properties"]["comments"].last["action"]
478 assert_equal "This is a hide comment", js["properties"]["comments"].last["text"]
479 assert_equal "moderator", js["properties"]["comments"].last["user"]
481 get :show, {:id => notes(:open_note_with_comment).id, :format => 'json'}
482 assert_response :gone
485 def test_destroy_fail
486 delete :destroy, {:id => 12345, :format => "json"}
487 assert_response :unauthorized
489 basic_authorization(users(:public_user).email, "test")
491 delete :destroy, {:id => 12345, :format => "json"}
492 assert_response :forbidden
494 basic_authorization(users(:moderator_user).email, "test")
496 delete :destroy, {:id => 12345, :format => "json"}
497 assert_response :not_found
499 delete :destroy, {:id => notes(:hidden_note_with_comment).id, :format => "json"}
500 assert_response :gone
503 def test_index_success
504 get :index, {:bbox => '1,1,1.2,1.2', :format => 'rss'}
505 assert_response :success
506 assert_equal "application/rss+xml", @response.content_type
507 assert_select "rss", :count => 1 do
508 assert_select "channel", :count => 1 do
509 assert_select "item", :count => 2
513 get :index, {:bbox => '1,1,1.2,1.2', :format => 'json'}
514 assert_response :success
515 assert_equal "application/json", @response.content_type
516 js = ActiveSupport::JSON.decode(@response.body)
518 assert_equal "FeatureCollection", js["type"]
519 assert_equal 2, js["features"].count
521 get :index, {:bbox => '1,1,1.2,1.2', :format => 'xml'}
522 assert_response :success
523 assert_equal "application/xml", @response.content_type
524 assert_select "osm", :count => 1 do
525 assert_select "note", :count => 2
528 get :index, {:bbox => '1,1,1.2,1.2', :format => 'gpx'}
529 assert_response :success
530 assert_equal "application/gpx+xml", @response.content_type
531 assert_select "gpx", :count => 1 do
532 assert_select "wpt", :count => 2
536 def test_index_empty_area
537 get :index, {:bbox => '5,5,5.1,5.1', :format => 'rss'}
538 assert_response :success
539 assert_equal "application/rss+xml", @response.content_type
540 assert_select "rss", :count => 1 do
541 assert_select "channel", :count => 1 do
542 assert_select "item", :count => 0
546 get :index, {:bbox => '5,5,5.1,5.1', :format => 'json'}
547 assert_response :success
548 assert_equal "application/json", @response.content_type
549 js = ActiveSupport::JSON.decode(@response.body)
551 assert_equal "FeatureCollection", js["type"]
552 assert_equal 0, js["features"].count
554 get :index, {:bbox => '5,5,5.1,5.1', :format => 'xml'}
555 assert_response :success
556 assert_equal "application/xml", @response.content_type
557 assert_select "osm", :count => 1 do
558 assert_select "note", :count => 0
561 get :index, {:bbox => '5,5,5.1,5.1', :format => 'gpx'}
562 assert_response :success
563 assert_equal "application/gpx+xml", @response.content_type
564 assert_select "gpx", :count => 1 do
565 assert_select "wpt", :count => 0
569 def test_index_large_area
570 get :index, {:bbox => '-2.5,-2.5,2.5,2.5', :format => :json}
571 assert_response :success
572 assert_equal "application/json", @response.content_type
574 get :index, {:l => '-2.5', :b => '-2.5', :r => '2.5', :t => '2.5', :format => :json}
575 assert_response :success
576 assert_equal "application/json", @response.content_type
578 get :index, {:bbox => '-10,-10,12,12', :format => :json}
579 assert_response :bad_request
580 assert_equal "text/plain", @response.content_type
582 get :index, {:l => '-10', :b => '-10', :r => '12', :t => '12', :format => :json}
583 assert_response :bad_request
584 assert_equal "text/plain", @response.content_type
587 def test_index_closed
588 get :index, {:bbox => '1,1,1.7,1.7', :closed => '7', :format => 'json'}
589 assert_response :success
590 assert_equal "application/json", @response.content_type
591 js = ActiveSupport::JSON.decode(@response.body)
593 assert_equal "FeatureCollection", js["type"]
594 assert_equal 4, js["features"].count
596 get :index, {:bbox => '1,1,1.7,1.7', :closed => '0', :format => 'json'}
597 assert_response :success
598 assert_equal "application/json", @response.content_type
599 js = ActiveSupport::JSON.decode(@response.body)
601 assert_equal "FeatureCollection", js["type"]
602 assert_equal 4, js["features"].count
604 get :index, {:bbox => '1,1,1.7,1.7', :closed => '-1', :format => 'json'}
605 assert_response :success
606 assert_equal "application/json", @response.content_type
607 js = ActiveSupport::JSON.decode(@response.body)
609 assert_equal "FeatureCollection", js["type"]
610 assert_equal 6, js["features"].count
613 def test_index_bad_params
614 get :index, {:bbox => '-2.5,-2.5,2.5'}
615 assert_response :bad_request
617 get :index, {:bbox => '-2.5,-2.5,2.5,2.5,2.5'}
618 assert_response :bad_request
620 get :index, {:b => '-2.5', :r => '2.5', :t => '2.5'}
621 assert_response :bad_request
623 get :index, {:l => '-2.5', :r => '2.5', :t => '2.5'}
624 assert_response :bad_request
626 get :index, {:l => '-2.5', :b => '-2.5', :t => '2.5'}
627 assert_response :bad_request
629 get :index, {:l => '-2.5', :b => '-2.5', :r => '2.5'}
630 assert_response :bad_request
632 get :index, {:bbox => '1,1,1.7,1.7', :limit => '0', :format => 'json'}
633 assert_response :bad_request
635 get :index, {:bbox => '1,1,1.7,1.7', :limit => '10001', :format => 'json'}
636 assert_response :bad_request
639 def test_search_success
640 get :search, {:q => 'note 1', :format => 'xml'}
641 assert_response :success
642 assert_equal "application/xml", @response.content_type
643 assert_select "osm", :count => 1 do
644 assert_select "note", :count => 1
647 get :search, {:q => 'note 1', :format => 'json'}
648 assert_response :success
649 assert_equal "application/json", @response.content_type
650 js = ActiveSupport::JSON.decode(@response.body)
652 assert_equal "FeatureCollection", js["type"]
653 assert_equal 1, js["features"].count
655 get :search, {:q => 'note 1', :format => 'rss'}
656 assert_response :success
657 assert_equal "application/rss+xml", @response.content_type
658 assert_select "rss", :count => 1 do
659 assert_select "channel", :count => 1 do
660 assert_select "item", :count => 1
664 get :search, {:q => 'note 1', :format => 'gpx'}
665 assert_response :success
666 assert_equal "application/gpx+xml", @response.content_type
667 assert_select "gpx", :count => 1 do
668 assert_select "wpt", :count => 1
672 def test_search_no_match
673 get :search, {:q => 'no match', :format => 'xml'}
674 assert_response :success
675 assert_equal "application/xml", @response.content_type
676 assert_select "osm", :count => 1 do
677 assert_select "note", :count => 0
680 get :search, {:q => 'no match', :format => 'json'}
681 assert_response :success
682 assert_equal "application/json", @response.content_type
683 js = ActiveSupport::JSON.decode(@response.body)
685 assert_equal "FeatureCollection", js["type"]
686 assert_equal 0, js["features"].count
688 get :search, {:q => 'no match', :format => 'rss'}
689 assert_response :success
690 assert_equal "application/rss+xml", @response.content_type
691 assert_select "rss", :count => 1 do
692 assert_select "channel", :count => 1 do
693 assert_select "item", :count => 0
697 get :search, {:q => 'no match', :format => 'gpx'}
698 assert_response :success
699 assert_equal "application/gpx+xml", @response.content_type
700 assert_select "gpx", :count => 1 do
701 assert_select "wpt", :count => 0
705 def test_search_bad_params
707 assert_response :bad_request
709 get :search, {:q => 'no match', :limit => '0', :format => 'json'}
710 assert_response :bad_request
712 get :search, {:q => 'no match', :limit => '10001', :format => 'json'}
713 assert_response :bad_request
716 def test_feed_success
717 get :feed, {:format => "rss"}
718 assert_response :success
719 assert_equal "application/rss+xml", @response.content_type
720 assert_select "rss", :count => 1 do
721 assert_select "channel", :count => 1 do
722 assert_select "item", :count => 8
726 get :feed, {:bbox => "1,1,1.2,1.2", :format => "rss"}
727 assert_response :success
728 assert_equal "application/rss+xml", @response.content_type
729 assert_select "rss", :count => 1 do
730 assert_select "channel", :count => 1 do
731 assert_select "item", :count => 3
737 get :feed, {:bbox => "1,1,1.2", :format => "rss"}
738 assert_response :bad_request
740 get :feed, {:bbox => "1,1,1.2,1.2,1.2", :format => "rss"}
741 assert_response :bad_request
743 get :feed, {:bbox => "1,1,1.2,1.2", :limit => '0', :format => "rss"}
744 assert_response :bad_request
746 get :feed, {:bbox => "1,1,1.2,1.2", :limit => '10001', :format => "rss"}
747 assert_response :bad_request
750 def test_mine_success
751 get :mine, {:display_name => "test"}
752 assert_response :success
754 get :mine, {:display_name => "pulibc_test2"}
755 assert_response :success
757 get :mine, {:display_name => "non-existent"}
758 assert_response :not_found