diff --git a/app/models/core_workflow/attributes/user.rb b/app/models/core_workflow/attributes/user.rb index 4700c0e46..36d3aee11 100644 --- a/app/models/core_workflow/attributes/user.rb +++ b/app/models/core_workflow/attributes/user.rb @@ -3,8 +3,11 @@ class CoreWorkflow::Attributes::User < CoreWorkflow::Attributes::Base def values - return ticket_owner_id_bulk if @attributes.payload['screen'] == 'overview_bulk' - return ticket_owner_id if @attributes.payload['class_name'] == 'Ticket' && @attribute[:name] == 'owner_id' + if @attribute[:name] == 'owner_id' && @attributes.payload['class_name'] == 'Ticket' + return ticket_owner_id_bulk if @attributes.payload['screen'] == 'overview_bulk' + + return ticket_owner_id + end [] end @@ -35,7 +38,10 @@ class CoreWorkflow::Attributes::User < CoreWorkflow::Attributes::Base def ticket_owner_id return [''] if @attributes.selected_only.group_id.blank? - group_owner_ids + owner_ids = group_owner_ids + return [''] if owner_ids.blank? + + owner_ids end def group_owner_ids diff --git a/spec/models/core_workflow_spec.rb b/spec/models/core_workflow_spec.rb index a98241f7a..711f582a0 100644 --- a/spec/models/core_workflow_spec.rb +++ b/spec/models/core_workflow_spec.rb @@ -207,6 +207,24 @@ RSpec.describe CoreWorkflow, type: :model do expect(result[:restrict_values]['owner_id']).to eq(['', action_user.id.to_s]) 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 describe '.perform - Default - State' do @@ -1717,4 +1735,21 @@ RSpec.describe CoreWorkflow, type: :model do 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