From 264ab24aed0f54a5f72352dafeb8fb03b1244a01 Mon Sep 17 00:00:00 2001 From: Mantas Date: Tue, 15 May 2018 16:20:59 +0300 Subject: [PATCH] Fixes #2011 user with granular permissions is shown only once in overlay --- .../app/controllers/ticket_overview.coffee | 4 +-- .../admin_drag_drop_to_new_group_test.rb | 30 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 4e70e80a4..66f654c0a 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -415,7 +415,7 @@ class App.TicketOverview extends App.Controller group = App.Group.find(groupId) users = [] - for user_id in group.user_ids + for user_id in _.uniq(group.user_ids) if App.User.exists(user_id) user = App.User.find(user_id) if user.active is true @@ -620,7 +620,7 @@ class App.TicketOverview extends App.Controller users.push user for group in groups valid_user_ids = [] - for user_id in group.user_ids + for user_id in _.uniq(group.user_ids) if App.User.exists(user_id) if App.User.find(user_id).active is true valid_user_ids.push user_id diff --git a/test/browser/admin_drag_drop_to_new_group_test.rb b/test/browser/admin_drag_drop_to_new_group_test.rb index a3e868dc8..7629b2248 100644 --- a/test/browser/admin_drag_drop_to_new_group_test.rb +++ b/test/browser/admin_drag_drop_to_new_group_test.rb @@ -43,13 +43,7 @@ class AdminDragDropToNewGroupTest < TestCase assert_not_nil(group) - checkbox = group.find_element(css: 'input[value=full]') - - @browser - .action - .move_to(checkbox, 0, 10) - .click - .perform + %w[read create].each { |val| toggle_checkbox(group, val) } click(css: '.modal button.js-submit') @@ -85,5 +79,27 @@ class AdminDragDropToNewGroupTest < TestCase group_description = new_group_container.find_element(css: '.batch-overlay-assign-entry-detail').text assert_equal('1 PEOPLE', group_description) + + @browser + .action + .move_to(new_group_container) + .perform + + sleep(1) + + users_in_group = @browser.find_elements(css: '.js-batch-assign-group-inner .batch-overlay-assign-entry[data-action=user_assign]') + assert_equal(1, users_in_group.count) + end + + private + + def toggle_checkbox(scope, value) + checkbox = scope.find_element(css: "input[value=#{value}]") + + @browser + .action + .move_to(checkbox, 0, 10) + .click + .perform end end