]> git.openstreetmap.org Git - rails.git/blob - test/functional/site_controller_test.rb
Fix user traces link's :action parameter
[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     @request.cookies["_osm_username"] = users(:public_user).display_name
47
48     get(:edit, nil, { 'user' => users(:public_user).id })
49     assert_response :success
50     assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
51   end
52
53   # and when they have...
54   def test_edit_with_preference
55     @request.cookies["_osm_username"] = users(:public_user).display_name
56
57     user = users(:public_user)
58     user.preferred_editor = "potlatch"
59     user.save!
60
61     get(:edit, nil, { 'user' => user.id })
62     assert_response :success
63     assert_template :partial => "_potlatch", :count => 1
64
65     user = users(:public_user)
66     user.preferred_editor = "remote"
67     user.save!
68
69     get(:edit, nil, { 'user' => user.id })
70     assert_response :success
71     assert_template "index"
72   end    
73 end