Fixed issue #2246 - Records in Reporting not updated when single ActiveRecord can not be found (fixes #2246)

This commit is contained in:
Billy Zhou 2018-09-26 21:33:17 +08:00
parent 58a8c047bb
commit 5ff371f51b
2 changed files with 44 additions and 2 deletions

View file

@ -169,8 +169,10 @@ returns
assets = {}
result[:ticket_ids].each do |ticket_id|
ticket_full = Ticket.find(ticket_id)
assets = ticket_full.assets(assets)
suppress(ActiveRecord::RecordNotFound) do
ticket_full = Ticket.find(ticket_id)
assets = ticket_full.assets(assets)
end
end
result[:assets] = assets
result

View file

@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe Report::TicketGenericTime do
=begin
result = Report::TicketGenericTime.items(
range_start: '2015-01-01T00:00:00Z',
range_end: '2015-12-31T23:59:59Z',
selector: selector, # ticket selector to get only a collection of tickets
params: { field: 'created_at' },
)
returns
{
count: 123,
ticket_ids: [4,5,1,5,0,51,5,56,7,4],
assets: assets,
}
=end
describe 'items' do
# Regression test for issue #2246 - Records in Reporting not updated when single ActiveRecord can not be found
it 'correctly handles missing tickets' do
class_double('SearchIndexBackend', selectors: { ticket_ids: [-1] } ).as_stubbed_const
expect do
described_class.items(
range_start: '2015-01-01T00:00:00Z',
range_end: '2015-12-31T23:59:59Z',
selector: {}, # ticket selector to get only a collection of tickets
params: { field: 'created_at' },
)
end.to_not raise_error
end
end
end