Skip to content

Commit

Permalink
Fixes #4599 - Error 500 if overview with "out of office replacement" …
Browse files Browse the repository at this point in the history
…filter is set to "specific user".
  • Loading branch information
rolfschmidt committed Aug 21, 2023
1 parent 46a1152 commit 78b2f6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/ticket/selector/sql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def condition_sql(block_condition)
else
if attribute_name == 'out_of_office_replacement_id'
query << "#{attribute} IN (?)"
bind_params.push User.find(block_condition[:value]).out_of_office_agent_of.pluck(:id)
bind_params.push User.where(id: Array.wrap(block_condition[:value])).map(&:out_of_office_agent_of).flatten.map(&:id)
else
if block_condition[:value].class != Array
block_condition[:value] = [block_condition[:value]]
Expand Down
28 changes: 28 additions & 0 deletions spec/models/ticket/selector/sql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,32 @@ def get_condition(operator, range)
expect(count).to eq(1)
end
end

describe 'Error 500 if overview with "out of office replacement" filter is set to "specific user" #4599' do
let(:agent) { create(:agent) }
let(:agent_ooo) { create(:agent, :ooo, ooo_agent: agent_ooo_replacement) }
let(:agent_ooo_replacement) { create(:agent) }
let(:condition) do
{
'ticket.out_of_office_replacement_id': {
operator: 'is',
pre_condition: 'specific',
value: [
agent_ooo_replacement.id.to_s,
],
value_completion: ''
}
}
end

before do
agent_ooo
end

it 'calculates the out of office user ids for the out of office replacement agent' do
_, bind_params = Ticket.selector2sql(condition)

expect(bind_params.flatten).to include(agent_ooo.id)
end
end
end

0 comments on commit 78b2f6d

Please sign in to comment.