From 915f66e495bb87a44a3bf079418768a7febc4eb9 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 2 Dec 2021 14:01:03 +0000 Subject: [PATCH] Add role to active admin --- app/admin/users.rb | 4 +++- spec/controllers/admin/users_controller_spec.rb | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/admin/users.rb b/app/admin/users.rb index 75575402d..781ef046c 100644 --- a/app/admin/users.rb +++ b/app/admin/users.rb @@ -1,5 +1,5 @@ ActiveAdmin.register User do - permit_params :name, :email, :password, :password_confirmation, :organisation_id + permit_params :name, :email, :password, :password_confirmation, :organisation_id, :role controller do def update_resource(object, attributes) @@ -14,6 +14,7 @@ ActiveAdmin.register User do column :name column :email column :organisation + column(:role) { |u| u.role.to_s.humanize } column :current_sign_in_at column :sign_in_count column :created_at @@ -34,6 +35,7 @@ ActiveAdmin.register User do f.input :password f.input :password_confirmation f.input :organisation + f.input :role end f.actions end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index a7615adba..bad96a9e6 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -30,6 +30,7 @@ describe Admin::UsersController, type: :controller do name: "Jane", password: "pAssword1", organisation_id: organisation.id, + role: "data_coordinator", }, } end @@ -49,6 +50,7 @@ describe Admin::UsersController, type: :controller do expect(page).to have_field("user_email") expect(page).to have_field("user_name") expect(page).to have_field("user_organisation_id") + expect(page).to have_field("user_role") expect(page).to have_field("user_password") expect(page).to have_field("user_password_confirmation") end