Initial work on support for multiple editors

This commit is contained in:
Matt Amos 2010-11-14 12:40:44 +00:00 committed by Tom Hughes
parent 7f955a4aca
commit cd66a5db99
13 changed files with 140 additions and 72 deletions

View file

@ -1,8 +1,9 @@
require File.dirname(__FILE__) + '/../test_helper'
class SiteControllerTest < ActionController::TestCase
## Lets check that we can get all the pages without any errors
fixtures :users
## Lets check that we can get all the pages without any errors
# Get the index
def test_index
get :index
@ -39,4 +40,22 @@ class SiteControllerTest < ActionController::TestCase
assert_template :partial => '_key', :count => count
assert_template :partial => '_sidebar', :count => count
end
# test the right editor gets used when the user hasn't set a preference
def test_edit_without_preference
get(:edit, nil, { 'user' => users(:public_user).id })
assert_response :success
assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
end
# and when they have...
def test_edit_with_preference
user = users(:public_user)
user.preferred_editor = "josm"
user.save!
get(:edit, nil, { 'user' => user.id })
assert_response :success
assert_template :partial => "_josm", :count => 1
end
end

View file

@ -138,4 +138,15 @@ class UserTest < ActiveSupport::TestCase
#Friend.delete(friend)
#assert_equal 0, Friend.count
end
def test_user_preferred_editor
user = users(:normal_user)
assert_equal nil, user.preferred_editor
user.preferred_editor = "potlatch"
assert_equal "potlatch", user.preferred_editor
user.save!
user.preferred_editor = "invalid_editor"
assert_raise(ActiveRecord::RecordInvalid) { user.save! }
end
end