Skip to content

Commit caeaf16

Browse files
committed
Execution Hanging Detection
Increasing code coverage. Signed-off-by: Rodrigo Nardi <rnardi@netdef.org>
1 parent 5235435 commit caeaf16

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

lib/models/check_suite.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ def execution_started?
5050
end
5151

5252
def last_job_updated_at_timer
53-
ci_jobs.max_by(&:updated_at).to_s.updated_at
53+
ci_jobs.max_by(&:updated_at)&.updated_at
5454
end
5555
end

spec/lib/models/check_suite_spec.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
end
2323
end
2424

25-
context '#last_job_updated_at_timer?' do
26-
let(:ci_job) { create(:ci_job, updated_at: nil) }
25+
context '#last_job_updated_at_timer? -> success' do
26+
let(:ci_job) { create(:ci_job) }
2727
let(:check_suite) { create(:check_suite, ci_jobs: [ci_job]) }
28-
let(:check_suite_running) { create(:check_suite, :with_in_progress) }
2928

3029
it 'returns false' do
31-
expect(check_suite_running.last_job_updated_at_timer).not_to be_nil
30+
expect(check_suite.last_job_updated_at_timer).not_to be_nil
31+
end
32+
end
33+
34+
context '#last_job_updated_at_timer? -> error' do
35+
let(:ci_job) { create(:ci_job, updated_at: nil) }
36+
let(:check_suite) { create(:check_suite, ci_jobs: []) }
37+
38+
it 'returns false' do
39+
expect(check_suite.last_job_updated_at_timer).to be_nil
3240
end
3341
end
3442
end

0 commit comments

Comments
 (0)