Commit 1ae557c1 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent ee4c8b75
...@@ -63,7 +63,7 @@ module CiStatusHelper ...@@ -63,7 +63,7 @@ module CiStatusHelper
render_status_with_link( render_status_with_link(
'commit', 'commit',
commit.status_for(ref), commit.status(ref),
path, path,
tooltip_placement: tooltip_placement) tooltip_placement: tooltip_placement)
end end
......
...@@ -230,11 +230,7 @@ class Commit ...@@ -230,11 +230,7 @@ class Commit
project.pipelines.where(sha: sha) project.pipelines.where(sha: sha)
end end
def status def status(ref = nil)
status_for(nil)
end
def status_for(ref)
if @statuses.key?(ref) if @statuses.key?(ref)
@statuses[ref] @statuses[ref]
elsif ref elsif ref
......
- status = commit.status_for(ref) - status = commit.status(ref)
- if status - if status
= link_to builds_namespace_project_commit_path(commit.project.namespace, commit.project, commit), class: "ci-status ci-#{status}" do = link_to builds_namespace_project_commit_path(commit.project.namespace, commit.project, commit), class: "ci-status ci-#{status}" do
= ci_icon_for_status(status) = ci_icon_for_status(status)
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
%span.commit-row-message.visible-xs-inline %span.commit-row-message.visible-xs-inline
· ·
= commit.short_id = commit.short_id
- if commit.status_for(ref) - if commit.status(ref)
.visible-xs-inline .visible-xs-inline
= render_commit_status(commit, ref: ref) = render_commit_status(commit, ref: ref)
- if commit.description? - if commit.description?
%a.text-expander.hidden-xs.js-toggle-button ... %a.text-expander.hidden-xs.js-toggle-button ...
.commit-actions.hidden-xs .commit-actions.hidden-xs
- if commit.status_for(ref) - if commit.status(ref)
= render_commit_status(commit, ref: ref) = render_commit_status(commit, ref: ref)
= clipboard_button(clipboard_text: commit.id) = clipboard_button(clipboard_text: commit.id)
= link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit-short-id btn btn-transparent" = link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit-short-id btn btn-transparent"
......
...@@ -210,6 +210,7 @@ eos ...@@ -210,6 +210,7 @@ eos
end end
describe '#status' do describe '#status' do
context 'without arguments for compound status' do
shared_examples 'giving the status from pipeline' do shared_examples 'giving the status from pipeline' do
it do it do
expect(commit.status).to eq(Ci::Pipeline.status) expect(commit.status).to eq(Ci::Pipeline.status)
...@@ -229,7 +230,7 @@ eos ...@@ -229,7 +230,7 @@ eos
end end
end end
describe '#status_for' do context 'when a particular ref is specified' do
let!(:pipeline_from_master) do let!(:pipeline_from_master) do
create(:ci_empty_pipeline, create(:ci_empty_pipeline,
project: project, project: project,
...@@ -247,12 +248,13 @@ eos ...@@ -247,12 +248,13 @@ eos
end end
it 'gives pipelines from a particular branch' do it 'gives pipelines from a particular branch' do
expect(commit.status_for('master')).to eq(pipeline_from_master.status) expect(commit.status('master')).to eq(pipeline_from_master.status)
expect(commit.status_for('fix')).to eq(pipeline_from_fix.status) expect(commit.status('fix')).to eq(pipeline_from_fix.status)
end end
it 'gives compound status if ref is nil' do it 'gives compound status if ref is nil' do
expect(commit.status_for(nil)).to eq(commit.status) expect(commit.status(nil)).to eq(commit.status)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment