Commit 28bae3b6 authored by Lin Jen-Shin's avatar Lin Jen-Shin Committed by Rémy Coutable

Resolve "tree/master shows incorrect CI build status"

parent f16c6269
...@@ -34,6 +34,7 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -34,6 +34,7 @@ class Projects::CommitController < Projects::ApplicationController
def pipelines def pipelines
@pipelines = @commit.pipelines.order(id: :desc) @pipelines = @commit.pipelines.order(id: :desc)
@pipelines = @pipelines.where(ref: params[:ref]) if params[:ref]
respond_to do |format| respond_to do |format|
format.html format.html
......
...@@ -94,7 +94,7 @@ module CiStatusHelper ...@@ -94,7 +94,7 @@ module CiStatusHelper
def render_project_pipeline_status(pipeline_status, tooltip_placement: 'auto left') def render_project_pipeline_status(pipeline_status, tooltip_placement: 'auto left')
project = pipeline_status.project project = pipeline_status.project
path = pipelines_project_commit_path(project, pipeline_status.sha) path = pipelines_project_commit_path(project, pipeline_status.sha, ref: pipeline_status.ref)
render_status_with_link( render_status_with_link(
'commit', 'commit',
...@@ -105,7 +105,7 @@ module CiStatusHelper ...@@ -105,7 +105,7 @@ module CiStatusHelper
def render_commit_status(commit, ref: nil, tooltip_placement: 'auto left') def render_commit_status(commit, ref: nil, tooltip_placement: 'auto left')
project = commit.project project = commit.project
path = pipelines_project_commit_path(project, commit) path = pipelines_project_commit_path(project, commit, ref: ref)
render_status_with_link( render_status_with_link(
'commit', 'commit',
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- link = commit_path(project, commit, merge_request: merge_request) - link = commit_path(project, commit, merge_request: merge_request)
- cache_key = [project.full_path, - cache_key = [project.full_path,
ref,
commit.id, commit.id,
Gitlab::CurrentSettings.current_application_settings, Gitlab::CurrentSettings.current_application_settings,
@path.presence, @path.presence,
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
- if commit.status(ref) - if commit.status(ref)
= render_commit_status(commit, ref: ref) = render_commit_status(commit, ref: ref)
.js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id) } } .js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id, ref: ref) } }
.commit-sha-group .commit-sha-group
.label.label-monospace .label.label-monospace
......
---
title: Fix pipeline status in branch/tag tree page
merge_request: 17995
author:
type: fixed
...@@ -89,7 +89,7 @@ feature 'Dashboard Projects' do ...@@ -89,7 +89,7 @@ feature 'Dashboard Projects' do
end end
describe 'with a pipeline', :clean_gitlab_redis_shared_state do describe 'with a pipeline', :clean_gitlab_redis_shared_state do
let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) } let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) }
before do before do
# Since the cache isn't updated when a new pipeline is created # Since the cache isn't updated when a new pipeline is created
...@@ -102,7 +102,7 @@ feature 'Dashboard Projects' do ...@@ -102,7 +102,7 @@ feature 'Dashboard Projects' do
visit dashboard_projects_path visit dashboard_projects_path
page.within('.controls') do page.within('.controls') do
expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit)}']") expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']")
expect(page).to have_css('.ci-status-link') expect(page).to have_css('.ci-status-link')
expect(page).to have_css('.ci-status-icon-success') expect(page).to have_css('.ci-status-icon-success')
expect(page).to have_link('Commit: passed') expect(page).to have_link('Commit: passed')
......
require 'spec_helper'
describe 'user reads pipeline status', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:v110_pipeline) { create_pipeline('v1.1.0', 'success') }
let(:x110_pipeline) { create_pipeline('x1.1.0', 'failed') }
before do
project.add_master(user)
project.repository.add_tag(user, 'x1.1.0', 'v1.1.0')
v110_pipeline
x110_pipeline
sign_in(user)
end
shared_examples 'visiting project tree' do
scenario 'sees the correct pipeline status' do
visit project_tree_path(project, expected_pipeline.ref)
wait_for_requests
page.within('.blob-commit-info') do
expect(page).to have_link('', href: project_pipeline_path(project, expected_pipeline))
expect(page).to have_selector(".ci-status-icon-#{expected_pipeline.status}")
end
end
end
it_behaves_like 'visiting project tree' do
let(:expected_pipeline) { v110_pipeline }
end
it_behaves_like 'visiting project tree' do
let(:expected_pipeline) { x110_pipeline }
end
def create_pipeline(ref, status)
create(:ci_pipeline,
project: project,
ref: ref,
sha: project.commit(ref).sha,
status: status)
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