1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'browse_controller'
4 class BrowseControllerTest < ActionController::TestCase
8 # test all routes which lead to this controller
11 { :path => "/browse/start", :method => :get },
12 { :controller => "browse", :action => "start" }
15 { :path => "/browse/node/1", :method => :get },
16 { :controller => "browse", :action => "node", :id => "1" }
19 { :path => "/browse/node/1/history", :method => :get },
20 { :controller => "browse", :action => "node_history", :id => "1" }
23 { :path => "/browse/way/1", :method => :get },
24 { :controller => "browse", :action => "way", :id => "1" }
27 { :path => "/browse/way/1/history", :method => :get },
28 { :controller => "browse", :action => "way_history", :id => "1" }
31 { :path => "/browse/relation/1", :method => :get },
32 { :controller => "browse", :action => "relation", :id => "1" }
35 { :path => "/browse/relation/1/history", :method => :get },
36 { :controller => "browse", :action => "relation_history", :id => "1" }
39 { :path => "/browse/changeset/1", :method => :get },
40 { :controller => "browse", :action => "changeset", :id => "1" }
46 assert_response :success
49 def test_read_relation
50 browse_check 'relation', relations(:visible_relation).relation_id
53 def test_read_relation_history
54 browse_check 'relation_history', relations(:visible_relation).relation_id
58 browse_check 'way', ways(:visible_way).way_id
61 def test_read_way_history
62 browse_check 'way_history', ways(:visible_way).way_id
66 browse_check 'node', nodes(:visible_node).node_id
69 def test_read_node_history
70 browse_check 'node_history', nodes(:visible_node).node_id
73 def test_read_changeset
74 browse_check 'changeset', changesets(:normal_user_first_change).id
77 # This is a convenience method for most of the above checks
78 # First we check that when we don't have an id, it will correctly return a 404
79 # then we check that we get the correct 404 when a non-existant id is passed
80 # then we check that it will get a successful response, when we do pass an id
81 def browse_check(type, id)
83 assert_response :not_found
84 assert_template 'not_found'
85 get type, {:id => -10} # we won't have an id that's negative
86 assert_response :not_found
87 assert_template 'not_found'
89 assert_response :success