Skip to content

Commit

Permalink
Merge pull request ManageIQ#16627 from yrudman/fix-error-in-timeout-c…
Browse files Browse the repository at this point in the history
…hecking-for-job-without-target

Fix error in timeout checking for job without target
  • Loading branch information
gtanzillo authored Dec 11, 2017
2 parents 5549221 + 7d0c95d commit 5729359
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def timeout!
end

def target_entity
target_class.constantize.find_by(:id => target_id)
target_class.constantize.find_by(:id => target_id) if target_class
end

def self.check_jobs_for_timeout
Expand Down
5 changes: 5 additions & 0 deletions spec/models/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@
expect(@job.timeout_adjustment).to eq(1)
expect(@image_scan_job.timeout_adjustment).to eq(1)
end

it "returns the correct adjusment 1 if target class was not defined" do
job_without_target = Job.create_job("VmScan", :target_class => nil)
expect(job_without_target.timeout_adjustment).to eq(1)
end
end
end

Expand Down

0 comments on commit 5729359

Please sign in to comment.