Permalink
Please
sign in to comment.
Browse files
Fixed issue #2692 - ticket auto assignment is not working if only one…
… excluded user is defined.
- Loading branch information
Showing
with
163 additions
and 158 deletions.
@@ -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 |
@@ -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 |
0 comments on commit
8c27cbb