Fixed issue #2692 - ticket auto assignment is not working if only one excluded user is defined.
This commit is contained in:
parent
8996134214
commit
8c27cbb05e
5 changed files with 163 additions and 158 deletions
|
@ -500,6 +500,8 @@ class App.TicketZoom extends App.Controller
|
||||||
if @Config.get('ticket_auto_assignment') is true
|
if @Config.get('ticket_auto_assignment') is true
|
||||||
if @ticket.owner_id is 1 && @permissionCheck('ticket.agent') && @ticket.editable('full')
|
if @ticket.owner_id is 1 && @permissionCheck('ticket.agent') && @ticket.editable('full')
|
||||||
userIdsIgnore = @Config.get('ticket_auto_assignment_user_ids_ignore') || []
|
userIdsIgnore = @Config.get('ticket_auto_assignment_user_ids_ignore') || []
|
||||||
|
if !_.isArray(userIdsIgnore)
|
||||||
|
userIdsIgnore = [userIdsIgnore]
|
||||||
userIgnored = false
|
userIgnored = false
|
||||||
currentUserId = App.Session.get('id')
|
currentUserId = App.Session.get('id')
|
||||||
for userIdIgnore in userIdsIgnore
|
for userIdIgnore in userIdsIgnore
|
||||||
|
|
|
@ -25,7 +25,6 @@ if [ "$LEVEL" == '1' ]; then
|
||||||
# test/browser/agent_navigation_and_title_test.rb
|
# test/browser/agent_navigation_and_title_test.rb
|
||||||
# test/browser/agent_organization_profile_test.rb
|
# test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_attachment_test.rb
|
rm test/browser/agent_ticket_attachment_test.rb
|
||||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
rm test/browser/agent_ticket_create_available_types_test.rb
|
rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
@ -107,7 +106,6 @@ elif [ "$LEVEL" == '2' ]; then
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_attachment_test.rb
|
rm test/browser/agent_ticket_attachment_test.rb
|
||||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
rm test/browser/agent_ticket_create_available_types_test.rb
|
rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
@ -189,7 +187,6 @@ elif [ "$LEVEL" == '3' ]; then
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
# test/browser/agent_ticket_attachment_test.rb
|
# test/browser/agent_ticket_attachment_test.rb
|
||||||
# test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
# rm test/browser/agent_ticket_create_available_types_test.rb
|
# rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
# rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
# rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
#rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
#rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
@ -271,7 +268,6 @@ elif [ "$LEVEL" == '4' ]; then
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_attachment_test.rb
|
rm test/browser/agent_ticket_attachment_test.rb
|
||||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
rm test/browser/agent_ticket_create_available_types_test.rb
|
rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
@ -352,7 +348,6 @@ elif [ "$LEVEL" == '5' ]; then
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_attachment_test.rb
|
rm test/browser/agent_ticket_attachment_test.rb
|
||||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
rm test/browser/agent_ticket_create_available_types_test.rb
|
rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
@ -436,7 +431,6 @@ elif [ "$LEVEL" == '6' ]; then
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
rm test/browser/agent_ticket_attachment_test.rb
|
rm test/browser/agent_ticket_attachment_test.rb
|
||||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
|
||||||
rm test/browser/agent_ticket_create_available_types_test.rb
|
rm test/browser/agent_ticket_create_available_types_test.rb
|
||||||
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
rm test/browser/agent_ticket_create_attachment_missing_after_reload_test.rb
|
||||||
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
rm test/browser/agent_ticket_create_cc_tokenizer_test.rb
|
||||||
|
|
29
spec/system/admin/settings/ticket_spec.rb
Normal file
29
spec/system/admin/settings/ticket_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Admin > Settings > Ticket', type: :system do
|
||||||
|
|
||||||
|
describe 'owner auto-assignment admin settings' do
|
||||||
|
it 'enable and disable feature' do
|
||||||
|
|
||||||
|
click(:manage)
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
click(:href, '#settings/ticket')
|
||||||
|
click(:href, '#auto_assignment')
|
||||||
|
expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false)
|
||||||
|
find('.js-ticketAutoAssignment').click()
|
||||||
|
expect(page).to have_field('ticket_auto_assignment', checked: true, visible: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
refresh
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
find('a[href="#auto_assignment"]').click()
|
||||||
|
expect(page).to have_field('ticket_auto_assignment', checked: true, visible: false)
|
||||||
|
find('.js-ticketAutoAssignment').click()
|
||||||
|
expect(page).to have_field('ticket_auto_assignment', checked: false, visible: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
132
spec/system/ticket/zoom_spec.rb
Normal file
132
spec/system/ticket/zoom_spec.rb
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Ticket zoom', type: :system do
|
||||||
|
|
||||||
|
describe 'owner auto-assignment' do
|
||||||
|
let!(:ticket) { create(:ticket, group: Group.find_by(name: 'Users'), state: Ticket::State.find_by(name: 'new')) }
|
||||||
|
let!(:session_user) { User.find_by(login: 'master@example.com') }
|
||||||
|
|
||||||
|
context 'for agent disabled' do
|
||||||
|
before do
|
||||||
|
Setting.set('ticket_auto_assignment', false)
|
||||||
|
Setting.set('ticket_auto_assignment_selector', { condition: { 'ticket.state_id' => { operator: 'is', value: Ticket::State.by_category(:work_on).pluck(:id) } } })
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', [])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'do not assign ticket to current session user' do
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: '-',
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for agent enabled' do
|
||||||
|
before do
|
||||||
|
Setting.set('ticket_auto_assignment', true)
|
||||||
|
Setting.set('ticket_auto_assignment_selector', { condition: { 'ticket.state_id' => { operator: 'is', value: Ticket::State.by_category(:work_on).pluck(:id) } } })
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with empty "ticket_auto_assignment_user_ids_ignore"' do
|
||||||
|
it 'assigns ticket to current session user' do
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('.content.active select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: session_user.fullname,
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with "ticket_auto_assignment_user_ids_ignore" (as integer)' do
|
||||||
|
it 'assigns ticket not to current session user' do
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', session_user.id)
|
||||||
|
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: '-',
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with "ticket_auto_assignment_user_ids_ignore" (as string)' do
|
||||||
|
it 'assigns ticket not to current session user' do
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', session_user.id.to_s)
|
||||||
|
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: '-',
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with "ticket_auto_assignment_user_ids_ignore" (as [integer])' do
|
||||||
|
it 'assigns ticket not to current session user' do
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', [session_user.id])
|
||||||
|
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: '-',
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with "ticket_auto_assignment_user_ids_ignore" (as [string])' do
|
||||||
|
it 'assigns ticket not to current session user' do
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', [session_user.id.to_s])
|
||||||
|
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: '-',
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with "ticket_auto_assignment_user_ids_ignore" and other user ids' do
|
||||||
|
it 'assigns ticket to current session user' do
|
||||||
|
Setting.set('ticket_auto_assignment_user_ids_ignore', [99_999, 999_999])
|
||||||
|
|
||||||
|
refresh
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
|
within(:active_content) do
|
||||||
|
expect(page).to have_css('select[name=owner_id]')
|
||||||
|
expect(page).to have_select('owner_id',
|
||||||
|
selected: session_user.fullname,
|
||||||
|
options: ['-', 'Agent 1 Test', 'Test Master Agent'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,152 +0,0 @@
|
||||||
require 'browser_test_helper'
|
|
||||||
|
|
||||||
class AgentTicketAutoAssignmentTest < TestCase
|
|
||||||
def test_ticket
|
|
||||||
|
|
||||||
@browser = browser_instance
|
|
||||||
login(
|
|
||||||
username: 'agent1@example.com',
|
|
||||||
password: 'test',
|
|
||||||
url: browser_url,
|
|
||||||
)
|
|
||||||
tasks_close_all()
|
|
||||||
|
|
||||||
#
|
|
||||||
# attachment checks - new ticket
|
|
||||||
#
|
|
||||||
|
|
||||||
# create new ticket with no attachment, attachment check should pop up
|
|
||||||
ticket1 = ticket_create(
|
|
||||||
data: {
|
|
||||||
customer: 'nico',
|
|
||||||
group: 'Users',
|
|
||||||
title: 'test_auto_assignment_1 - ticket 1',
|
|
||||||
body: 'test_auto_assignment_1 - ticket 1 - no auto assignment',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
ticket2 = ticket_create(
|
|
||||||
data: {
|
|
||||||
customer: 'nico',
|
|
||||||
group: 'Users',
|
|
||||||
title: 'test_auto_assignment_2 - ticket 2',
|
|
||||||
body: 'test_auto_assignment_2 - ticket 2 - no auto assignment',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
ticket3 = ticket_create(
|
|
||||||
data: {
|
|
||||||
customer: 'nico',
|
|
||||||
group: 'Users',
|
|
||||||
title: 'test_auto_assignment_3 - ticket 3',
|
|
||||||
body: 'test_auto_assignment_3 - ticket 3 - no auto assignment',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks_close_all()
|
|
||||||
|
|
||||||
logout()
|
|
||||||
|
|
||||||
login(
|
|
||||||
username: 'master@example.com',
|
|
||||||
password: 'test',
|
|
||||||
url: browser_url,
|
|
||||||
)
|
|
||||||
tasks_close_all()
|
|
||||||
|
|
||||||
# open ticket#1
|
|
||||||
ticket_open_by_search(
|
|
||||||
number: ticket1[:number],
|
|
||||||
)
|
|
||||||
|
|
||||||
# verify if owner is set
|
|
||||||
match(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: '-',
|
|
||||||
)
|
|
||||||
|
|
||||||
# open ticket#2
|
|
||||||
ticket_open_by_search(
|
|
||||||
number: ticket2[:number],
|
|
||||||
)
|
|
||||||
|
|
||||||
# verify if owner is set
|
|
||||||
match(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: '-',
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks_close_all()
|
|
||||||
|
|
||||||
# enable auto assignment
|
|
||||||
click(css: 'a[href="#manage"]')
|
|
||||||
click(css: '.content.active a[href="#settings/ticket"]')
|
|
||||||
click(css: '.content.active a[href="#auto_assignment"]')
|
|
||||||
switch(
|
|
||||||
css: '.content.active .js-ticketAutoAssignment',
|
|
||||||
type: 'on',
|
|
||||||
)
|
|
||||||
|
|
||||||
# open ticket#1
|
|
||||||
ticket_open_by_search(
|
|
||||||
number: ticket1[:number],
|
|
||||||
)
|
|
||||||
|
|
||||||
# verify if owner is set
|
|
||||||
watch_for(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: 'Test Master',
|
|
||||||
timeout: 2,
|
|
||||||
)
|
|
||||||
|
|
||||||
# open ticket#2
|
|
||||||
ticket_open_by_search(
|
|
||||||
number: ticket2[:number],
|
|
||||||
)
|
|
||||||
|
|
||||||
# verify if owner is set
|
|
||||||
watch_for(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: 'Test Master',
|
|
||||||
timeout: 2,
|
|
||||||
)
|
|
||||||
|
|
||||||
# define auto assignment exception
|
|
||||||
click(css: 'a[href="#manage"]')
|
|
||||||
# flanky
|
|
||||||
click(css: '.content.active a[href="#settings/ticket"]')
|
|
||||||
click(css: '.content.active a[href="#auto_assignment"]')
|
|
||||||
click(css: '.content.active .js-select.js-option[title="master@example.com"]')
|
|
||||||
click(css: '.content.active .js-timeAccountingFilter')
|
|
||||||
|
|
||||||
watch_for_disappear(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: 'Test Master',
|
|
||||||
timeout: 10,
|
|
||||||
)
|
|
||||||
|
|
||||||
# open ticket#3
|
|
||||||
ticket_open_by_search(
|
|
||||||
number: ticket3[:number],
|
|
||||||
)
|
|
||||||
|
|
||||||
# verify if owner is not set
|
|
||||||
sleep 6
|
|
||||||
match(
|
|
||||||
css: '.content.active .sidebar select[name="owner_id"]',
|
|
||||||
value: '-',
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks_close_all()
|
|
||||||
|
|
||||||
# disable auto assignment
|
|
||||||
click(css: 'a[href="#manage"]')
|
|
||||||
click(css: '.content.active a[href="#settings/ticket"]')
|
|
||||||
click(css: '.content.active a[href="#auto_assignment"]')
|
|
||||||
switch(
|
|
||||||
css: '.content.active .js-ticketAutoAssignment',
|
|
||||||
type: 'off',
|
|
||||||
)
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue