Don't try to load status when there is no commit

This could happen when the repository is missing.

In which case cache needs to be cleared
This commit is contained in:
Bob Van Landuyt 2017-03-14 20:46:34 +01:00
parent c4956091e1
commit 21c5270a39
2 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,8 @@ module Ci
end
def load_from_commit
return unless commit
self.sha = commit.sha
self.status = commit.status
end

View File

@ -79,6 +79,14 @@ describe Ci::PipelineStatus do
expect(pipeline_status.status).to eq('success')
expect(pipeline_status.sha).to eq(project.commit.sha)
end
it "doesn't fail for an empty project" do
status_for_empty_commit = described_class.new(create(:empty_project))
status_for_empty_commit.load_status
expect(status_for_empty_commit).to be_loaded
end
end
describe "#store_in_cache", :redis do