]> git.openstreetmap.org Git - rails.git/blob - test/functional/site_controller_test.rb
Update expected GPS namespace in tests
[rails.git] / test / functional / site_controller_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class SiteControllerTest < ActionController::TestCase
4   fixtures :users
5
6   ## Lets check that we can get all the pages without any errors  
7   # Get the index
8   def test_index
9     get :index
10     assert_response :success
11     assert_template 'index'
12     assert_site_partials
13   end
14   
15   # Get the edit page
16   def test_edit
17     get :edit
18     # Should be redirected
19     assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
20   end
21   
22   # Get the export page
23   def test_export
24     get :export
25     assert_response :success
26     assert_template 'index'
27     assert_site_partials
28   end
29   
30   # Offline page
31   def test_offline
32     get :offline
33     assert_response :success
34     assert_template 'offline'
35     assert_site_partials 0
36   end
37   
38   def assert_site_partials(count = 1)
39     assert_template :partial => '_search', :count => count
40     assert_template :partial => '_key', :count => count
41     assert_template :partial => '_sidebar', :count => count
42   end
43
44   # test the right editor gets used when the user hasn't set a preference
45   def test_edit_without_preference
46     get(:edit, nil, { 'user' => users(:public_user).id })
47     assert_response :success
48     assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
49   end
50
51   # and when they have...
52   def test_edit_with_preference
53     user = users(:public_user)
54     user.preferred_editor = "potlatch"
55     user.save!
56
57     get(:edit, nil, { 'user' => user.id })
58     assert_response :success
59     assert_template :partial => "_potlatch", :count => 1
60
61     user = users(:public_user)
62     user.preferred_editor = "remote"
63     user.save!
64
65     get(:edit, nil, { 'user' => user.id })
66     assert_response :success
67     assert_template "index"
68   end    
69 end