Permalink
Browse files

Fixed issue #2246 - Records in Reporting not updated when single Acti…

…veRecord can not be found (fixes #2246)
  • Loading branch information...
SummerStorm committed Sep 26, 2018
1 parent 58a8c04 commit 5ff371f51bbb84b32c37a0adc5e05295f53fc9f9
Showing with 44 additions and 2 deletions.
  1. +4 −2 lib/report/ticket_generic_time.rb
  2. +40 −0 spec/lib/report/ticket_generic_time_spec.rb
@@ -169,8 +169,10 @@ def self.items(params)
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
@@ -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

0 comments on commit 5ff371f

Please sign in to comment.