Fixes #3818 - Owner should get cleared if not listed in changed group.
This commit is contained in:
parent
501a98b6c2
commit
8530951154
3 changed files with 36 additions and 7 deletions
|
@ -238,13 +238,10 @@ class CoreWorkflow::Attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
def saved_attribute_value(attribute)
|
def saved_attribute_value(attribute)
|
||||||
saved_attribute_value = saved_only&.try(attribute[:name])
|
|
||||||
|
|
||||||
# special case for owner_id
|
# special case for owner_id
|
||||||
if saved_only&.class == Ticket && attribute[:name] == 'owner_id' && saved_attribute_value == 1
|
return if saved_only&.class == Ticket && attribute[:name] == 'owner_id'
|
||||||
saved_attribute_value = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
saved_attribute_value
|
saved_only&.try(attribute[:name])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -322,10 +322,10 @@ RSpec.describe 'Ticket Update', type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when group will be changed' do
|
context 'when group will be changed' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { User.find_by(email: 'agent1@example.com') }
|
||||||
let(:ticket) { create(:ticket, group: group, owner: user) }
|
let(:ticket) { create(:ticket, group: group, owner: user) }
|
||||||
|
|
||||||
it 'check that owner is resetet after group change' do
|
it 'check that owner resets after group change' do
|
||||||
visit "#ticket/zoom/#{ticket.id}"
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
|
||||||
expect(page).to have_field('owner_id', with: user.id)
|
expect(page).to have_field('owner_id', with: user.id)
|
||||||
|
|
|
@ -2235,4 +2235,36 @@ RSpec.describe 'Ticket zoom', type: :system do
|
||||||
expect(page).to have_selector('form.article-add.is-open')
|
expect(page).to have_selector('form.article-add.is-open')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'Owner should get cleared if not listed in changed group #3818', authenticated_as: :authenticate do
|
||||||
|
let(:group1) { create(:group) }
|
||||||
|
let(:group2) { create(:group) }
|
||||||
|
let(:agent1) { create(:agent) }
|
||||||
|
let(:agent2) { create(:agent) }
|
||||||
|
let(:ticket) { create(:ticket, group: group1, owner: agent1) }
|
||||||
|
|
||||||
|
def authenticate
|
||||||
|
agent1.group_names_access_map = {
|
||||||
|
group1.name => 'full',
|
||||||
|
group2.name => %w[read change overview]
|
||||||
|
}
|
||||||
|
agent2.group_names_access_map = {
|
||||||
|
group1.name => 'full',
|
||||||
|
group2.name => 'full',
|
||||||
|
}
|
||||||
|
agent1
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit "#ticket/zoom/#{ticket.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does clear agent1 on select of group 2' do
|
||||||
|
select group2.name, from: 'Group'
|
||||||
|
wait(5).until { page.find('select[name=owner_id]').value != agent1.id.to_s }
|
||||||
|
expect(page.find('select[name=owner_id]').value).to eq('')
|
||||||
|
expect(page.all('select[name=owner_id] option').map(&:value)).not_to include(agent1.id.to_s)
|
||||||
|
expect(page.all('select[name=owner_id] option').map(&:value)).to include(agent2.id.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue