]> git.openstreetmap.org Git - rails.git/blob - test/functional/browse_controller_test.rb
Merge 16110:16487 from trunk.
[rails.git] / test / functional / browse_controller_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'browse_controller'
3
4 class BrowseControllerTest < ActionController::TestCase
5   api_fixtures
6
7   def test_start
8     get :start
9     assert_response :success
10   end
11   
12   def test_read_relation
13     browse_check 'relation', relations(:visible_relation)
14   end
15   
16   def test_read_relation_history
17     browse_check 'relation_history', relations(:visible_relation)
18   end
19   
20   def test_read_way
21     browse_check 'way', ways(:visible_way)
22   end
23   
24   def test_read_way_history
25     browse_check 'way_history', ways(:visible_way)
26   end
27   
28   def test_read_node
29     browse_check 'node', nodes(:visible_node)
30   end
31   
32   def test_read_node_history
33     browse_check 'node_history', nodes(:visible_node)
34   end
35   
36   def test_read_changeset
37     browse_check 'changeset', changesets(:normal_user_first_change)
38   end
39   
40   # This is a convenience method for most of the above checks
41   # First we check that when we don't have an id, it will correctly return a 404
42   # then we check that we get the correct 404 when a non-existant id is passed
43   # then we check that it will get a successful response, when we do pass an id
44   def browse_check(type, fixture) 
45     get type
46     assert_response :not_found
47     assert_template 'not_found'
48     get type, {:id => -10} # we won't have an id that's negative
49     assert_response :not_found
50     assert_template 'not_found'
51     get type, {:id => fixture.id}
52     assert_response :success
53     assert_template type
54   end
55 end