diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/controllers/users_controller_test.rb | 27 | ||||
| -rw-r--r-- | test/fixtures/users.yml | 3 |
2 files changed, 19 insertions, 11 deletions
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 67f7c053..1c5d16fc 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb | |||
| @@ -9,12 +9,12 @@ class UsersControllerTest < ActionController::TestCase | |||
| 9 | assert_select "a", { :count => 0, :text => "Destroy" } | 9 | assert_select "a", { :count => 0, :text => "Destroy" } |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | test "get index as admin user renders admin partial" do | 12 | test "get index as admin shows every group with per-row actions" do |
| 13 | login_as :aaron | 13 | login_as :aaron |
| 14 | get :index | 14 | get :index |
| 15 | assert_response :success | 15 | assert_response :success |
| 16 | assert_select "button[type=submit]", I18n.t("admin.common.destroy") | 16 | assert_select "button[type=submit]", I18n.t("admin.common.destroy") |
| 17 | assert_select "a", "show" | 17 | assert_select "a", I18n.t("admin.common.show") |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | test "get new when logged in as admin" do | 20 | test "get new when logged in as admin" do |
| @@ -60,7 +60,7 @@ class UsersControllerTest < ActionController::TestCase | |||
| 60 | :email => "foo@bar.com", | 60 | :email => "foo@bar.com", |
| 61 | :password => "xxxzzz", | 61 | :password => "xxxzzz", |
| 62 | :password_confirmation => "xxxzzz", | 62 | :password_confirmation => "xxxzzz", |
| 63 | :admin => true | 63 | :roles => ["admin", "redaktion"] |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | end | 66 | end |
| @@ -174,19 +174,17 @@ class UsersControllerTest < ActionController::TestCase | |||
| 174 | test "admin user can promote regular users to admins" do | 174 | test "admin user can promote regular users to admins" do |
| 175 | login_as :aaron | 175 | login_as :aaron |
| 176 | user = users(:quentin) | 176 | user = users(:quentin) |
| 177 | put :update, params: { :id => user.id, :user => {:admin => true} } | 177 | put :update, params: { :id => user.id, :user => {:roles => ["admin", "redaktion"]} } |
| 178 | 178 | ||
| 179 | user.reload | 179 | assert_equal true, user.reload.is_admin? |
| 180 | assert_equal true, user.is_admin? | ||
| 181 | end | 180 | end |
| 182 | 181 | ||
| 183 | test "regular users cannot promote themselves to admins" do | 182 | test "regular users cannot promote themselves to admins" do |
| 184 | login_as :quentin | 183 | login_as :quentin |
| 185 | user = users(:quentin) | 184 | user = users(:quentin) |
| 186 | put :update, params: { :id => user.id, :user => {:admin => true} } | 185 | put :update, params: { :id => user.id, :user => {:roles => ["admin", "redaktion"]} } |
| 187 | 186 | ||
| 188 | user.reload | 187 | assert_equal false, user.reload.is_admin? |
| 189 | assert_equal false, user.is_admin? | ||
| 190 | end | 188 | end |
| 191 | 189 | ||
| 192 | test "reset_otp is admin-only and witnessed" do | 190 | test "reset_otp is admin-only and witnessed" do |
| @@ -202,4 +200,15 @@ class UsersControllerTest < ActionController::TestCase | |||
| 202 | assert_not user.reload.otp_enrolled? | 200 | assert_not user.reload.otp_enrolled? |
| 203 | assert_equal "otp_reset", NodeAction.last.action | 201 | assert_equal "otp_reset", NodeAction.last.action |
| 204 | end | 202 | end |
| 203 | |||
| 204 | test "index groups a retired admin under alumni, not administration" do | ||
| 205 | login_as :aaron | ||
| 206 | user = users(:quentin) | ||
| 207 | user.update_column(:roles, ["admin", "alumni"]) | ||
| 208 | |||
| 209 | get :index | ||
| 210 | |||
| 211 | assert_response :success | ||
| 212 | assert_select "h2", :text => /#{I18n.t("users.index.group_alumni")}/ | ||
| 213 | end | ||
| 205 | end | 214 | end |
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 7276bcb4..f8d32d3c 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml | |||
| @@ -13,5 +13,4 @@ aaron: | |||
| 13 | salt: 5be6f9cdd04fd7ab3c91cd32a5334ba2339b8005 | 13 | salt: 5be6f9cdd04fd7ab3c91cd32a5334ba2339b8005 |
| 14 | crypted_password: 740a48caf7dd5ff11318d812d57c0a0928cfbc12 # 'monkey' | 14 | crypted_password: 740a48caf7dd5ff11318d812d57c0a0928cfbc12 # 'monkey' |
| 15 | created_at: 2024-01-02 00:00:00 | 15 | created_at: 2024-01-02 00:00:00 |
| 16 | admin: true | 16 | roles: ["admin", "redaktion"] |
| 17 | |||
