diff options
| author | hukl <contact@smyck.org> | 2009-11-03 20:16:40 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-11-03 20:16:40 +0100 |
| commit | 0c186fe46bbd5fa0b09ea9025c0d6ed256d8d11d (patch) | |
| tree | 963a74ebada9e1479656a03d644683a2f6929991 /test/functional/users_controller_test.rb | |
| parent | 3b35b3a0bba7991a243eb794303b838ae90bb69c (diff) | |
Prevent regular users from promoting themselves to admins
Diffstat (limited to 'test/functional/users_controller_test.rb')
| -rw-r--r-- | test/functional/users_controller_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 307ba4c..89c6dc2 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb | |||
| @@ -158,5 +158,23 @@ class UsersControllerTest < ActionController::TestCase | |||
| 158 | assert_redirected_to users_path | 158 | assert_redirected_to users_path |
| 159 | end | 159 | end |
| 160 | 160 | ||
| 161 | test "admin user can promote regular users to admins" do | ||
| 162 | login_as :aaron | ||
| 163 | user = users(:quentin) | ||
| 164 | put :update, :id => user.id, :user => {:admin => true} | ||
| 165 | |||
| 166 | user.reload | ||
| 167 | assert_equal true, user.is_admin? | ||
| 168 | end | ||
| 169 | |||
| 170 | test "regular users cannot promote themselves to admins" do | ||
| 171 | login_as :quentin | ||
| 172 | user = users(:quentin) | ||
| 173 | put :update, :id => user.id, :user => {:admin => true} | ||
| 174 | |||
| 175 | user.reload | ||
| 176 | assert_equal false, user.is_admin? | ||
| 177 | end | ||
| 178 | |||
| 161 | 179 | ||
| 162 | end | 180 | end |
