diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-04-20 18:20:30 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-04-20 19:25:02 +0300 |
commit | bae1644015592c3e432832ec6a0ac07770d46685 (patch) | |
tree | 0cb0ffc7aab45c0310e76640d86286d5e4d365ba /app/controllers/admin/groups_controller.rb | |
parent | 9e4908afa6597bf598c24fa54ce13d6efb57cf38 (diff) |
Refactor Admin::GroupsController#members_update method and add some specs
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/admin/groups_controller.rb')
-rw-r--r-- | app/controllers/admin/groups_controller.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index f28bbdeff5a..fc8d4d02ddf 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -43,9 +43,13 @@ class Admin::GroupsController < Admin::ApplicationController end def members_update - @group.add_users(params[:user_ids].split(','), params[:access_level], current_user: current_user) + status = Members::CreateService.new(@group, current_user, params).execute - redirect_to [:admin, @group], notice: 'Users were successfully added.' + if status + redirect_to [:admin, @group], notice: 'Users were successfully added.' + else + redirect_to [:admin, @group], alert: 'No users specified.' + end end def destroy |