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 get(:edit, nil, { 'user' => users(:public_user).id })
47 assert_response :success
48 assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
51 # and when they have...
52 def test_edit_with_preference
53 user = users(:public_user)
54 user.preferred_editor = "potlatch"
57 get(:edit, nil, { 'user' => user.id })
58 assert_response :success
59 assert_template :partial => "_potlatch", :count => 1
61 user = users(:public_user)
62 user.preferred_editor = "remote"
65 get(:edit, nil, { 'user' => user.id })
66 assert_response :success
67 assert_template "index"