Fixes #3809 - Ticket owner selection is not updated if owner selection should be empty.

This commit is contained in:
Rolf Schmidt 2021-10-15 11:08:35 +02:00
parent 485196b013
commit 0f4c6ddda3
2 changed files with 44 additions and 3 deletions

View file

@ -3,8 +3,11 @@
class CoreWorkflow::Attributes::User < CoreWorkflow::Attributes::Base class CoreWorkflow::Attributes::User < CoreWorkflow::Attributes::Base
def values def values
return ticket_owner_id_bulk if @attributes.payload['screen'] == 'overview_bulk' if @attribute[:name] == 'owner_id' && @attributes.payload['class_name'] == 'Ticket'
return ticket_owner_id if @attributes.payload['class_name'] == 'Ticket' && @attribute[:name] == 'owner_id' return ticket_owner_id_bulk if @attributes.payload['screen'] == 'overview_bulk'
return ticket_owner_id
end
[] []
end end
@ -35,7 +38,10 @@ class CoreWorkflow::Attributes::User < CoreWorkflow::Attributes::Base
def ticket_owner_id def ticket_owner_id
return [''] if @attributes.selected_only.group_id.blank? return [''] if @attributes.selected_only.group_id.blank?
group_owner_ids owner_ids = group_owner_ids
return [''] if owner_ids.blank?
owner_ids
end end
def group_owner_ids def group_owner_ids

View file

@ -207,6 +207,24 @@ RSpec.describe CoreWorkflow, type: :model do
expect(result[:restrict_values]['owner_id']).to eq(['', action_user.id.to_s]) expect(result[:restrict_values]['owner_id']).to eq(['', action_user.id.to_s])
end end
end end
describe 'Ticket owner selection is not updated if owner selection should be empty #3809' do
let(:group_no_owners) { create(:group) }
let(:ticket2) { create(:ticket, group: group_no_owners) }
let(:payload) do
base_payload.merge('screen' => 'overview_bulk', 'params' => { 'ticket_ids' => ticket2.id.to_s })
end
before do
action_user.group_names_access_map = {
group_no_owners.name => %w[create read change overview],
}
end
it 'does not show any owners for group with no full permitted users' do
expect(result[:restrict_values]['owner_id']).to eq([''])
end
end
end end
describe '.perform - Default - State' do describe '.perform - Default - State' do
@ -1717,4 +1735,21 @@ RSpec.describe CoreWorkflow, type: :model do
end end
end end
end end
describe 'Ticket owner selection is not updated if owner selection should be empty #3809' do
let(:group_no_owners) { create(:group) }
let(:payload) do
base_payload.merge('params' => { 'group_id' => group_no_owners.id })
end
before do
action_user.group_names_access_map = {
group_no_owners.name => %w[create read change overview],
}
end
it 'does not show any owners because no one has full permissions' do
expect(result[:restrict_values]['owner_id']).to eq([''])
end
end
end end