1 require File.dirname(__FILE__) + '/../test_helper'
3 class SiteControllerTest < ActionController::TestCase
6 ## Lets check that we can get all the pages without any errors
10 assert_response :success
11 assert_template 'index'
18 # Should be redirected
19 assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
25 assert_response :success
26 assert_template 'index'
33 assert_response :success
34 assert_template 'offline'
35 assert_site_partials 0
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
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
48 get(:edit, nil, { 'user' => users(:public_user).id })
49 assert_response :success
50 assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
53 # and when they have...
54 def test_edit_with_preference
55 @request.cookies["_osm_username"] = users(:public_user).display_name
57 user = users(:public_user)
58 user.preferred_editor = "potlatch"
61 get(:edit, nil, { 'user' => user.id })
62 assert_response :success
63 assert_template :partial => "_potlatch", :count => 1
65 user = users(:public_user)
66 user.preferred_editor = "remote"
69 get(:edit, nil, { 'user' => user.id })
70 assert_response :success
71 assert_template "index"