0
@@ -5,7 +5,7 @@ require 'admin/users_controller'
0
class Admin::UsersController; def rescue_action(e) raise e end; end
0
class Admin::UsersControllerTest < Test::Unit::TestCase
0
- fixtures :users, :sites, :memberships
0
+ fixtures :users, :sites, :memberships
, :contents0
@controller = Admin::UsersController.new
0
@request = ActionController::TestRequest.new
0
@@ -167,11 +167,36 @@ class Admin::UsersControllerTest < Test::Unit::TestCase
0
- def test_should_
disable_site_admin
0
+ def test_should_
toggle_site_admin_as_admin
0
xhr :post, :admin, :id => users(:arthur).id
0
assert_response :success
0
assert !sites(:first).user(users(:arthur).id).site_admin?
0
+ assert_match /Flash\.notice/, @response.body
0
+ def test_should_toggle_site_admin_as_site_admin
0
+ assert !sites(:first).user(users(:ben).id).site_admin?
0
+ xhr :post, :admin, :id => users(:ben).id
0
+ assert_response :success
0
+ assert sites(:first).user(users(:ben).id).site_admin?
0
+ assert_match /Flash\.notice/, @response.body
0
+ def test_should_not_toggle_site_admin_for_admin
0
+ xhr :post, :admin, :id => users(:quentin).id
0
+ assert_response :success
0
+ assert_match /Flash\.errors/, @response.body
0
+ def test_should_not_toggle_site_admin_for_self
0
+ xhr :post, :admin, :id => users(:arthur).id
0
+ assert_response :success
0
+ assert sites(:first).user(users(:arthur).id).site_admin?
0
+ assert_match /Flash\.errors/, @response.body
0
def test_should_enable_site_admin
0
@@ -186,12 +211,35 @@ class Admin::UsersControllerTest < Test::Unit::TestCase
0
assert_no_difference User, :count_with_deleted do
0
assert_difference User, :count, -1 do
0
- xhr :post, :destroy, :id => users(:
quentin).id
0
+ xhr :post, :destroy, :id => users(:
arthur).id
0
assert_response :success
0
+ assert_match /Flash\.notice/, @response.body
0
- assert_equal users(:quentin), User.find_with_deleted(users(:quentin).id)
0
+ assert_equal users(:arthur), User.find_with_deleted(users(:arthur).id)
0
+ def test_should_not_disable_admin
0
+ assert_no_difference User, :count_with_deleted do
0
+ assert_no_difference User, :count do
0
+ xhr :post, :destroy, :id => users(:quentin).id
0
+ assert_response :success
0
+ assert_match /Flash\.errors/, @response.body
0
+ def test_should_not_disable_self
0
+ assert_no_difference User, :count_with_deleted do
0
+ assert_no_difference User, :count do
0
+ xhr :post, :destroy, :id => users(:arthur).id
0
+ assert_response :success
0
+ assert_match /Flash\.errors/, @response.body
0
def test_should_enable_user
Comments
No one has commented yet.