Commit 2dd5db74 authored by Takuya Noguchi's avatar Takuya Noguchi

Add sorting pipeline for a commit

parent 6c624821
...@@ -12,7 +12,6 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -12,7 +12,6 @@ class Projects::CommitController < Projects::ApplicationController
before_action :authorize_read_pipeline!, only: [:pipelines] before_action :authorize_read_pipeline!, only: [:pipelines]
before_action :commit before_action :commit
before_action :define_commit_vars, only: [:show, :diff_for_path, :pipelines] before_action :define_commit_vars, only: [:show, :diff_for_path, :pipelines]
before_action :define_status_vars, only: [:show, :pipelines]
before_action :define_note_vars, only: [:show, :diff_for_path] before_action :define_note_vars, only: [:show, :diff_for_path]
before_action :authorize_edit_tree!, only: [:revert, :cherry_pick] before_action :authorize_edit_tree!, only: [:revert, :cherry_pick]
...@@ -106,10 +105,6 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -106,10 +105,6 @@ class Projects::CommitController < Projects::ApplicationController
} }
end end
def define_status_vars
@ci_pipelines = project.pipelines.where(sha: commit.sha)
end
def assign_change_commit_vars(mr_source_branch) def assign_change_commit_vars(mr_source_branch)
@commit = project.commit(params[:id]) @commit = project.commit(params[:id])
@target_branch = params[:target_branch] @target_branch = params[:target_branch]
......
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
= nav_link(path: 'commit#pipelines') do = nav_link(path: 'commit#pipelines') do
= link_to pipelines_namespace_project_commit_path(@project.namespace, @project, @commit.id) do = link_to pipelines_namespace_project_commit_path(@project.namespace, @project, @commit.id) do
Pipelines Pipelines
%span.badge= @ci_pipelines.count %span.badge= @commit.pipelines.size
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
= render "commit_box" = render "commit_box"
= render "ci_menu" = render "ci_menu"
= render "pipelines_list", pipelines: @ci_pipelines = render "pipelines_list", pipelines: @commit.pipelines.order(id: :desc)
---
title: Add sorting pipeline for a commit
merge_request: 8319
author: Takuya Noguchi
...@@ -4,6 +4,7 @@ describe Projects::CommitController do ...@@ -4,6 +4,7 @@ describe Projects::CommitController do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.commit("master") } let(:commit) { project.commit("master") }
let(:pipeline) { create(:ci_pipeline, project: project, commit: commit) }
let(:master_pickable_sha) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' } let(:master_pickable_sha) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' }
let(:master_pickable_commit) { project.commit(master_pickable_sha) } let(:master_pickable_commit) { project.commit(master_pickable_sha) }
...@@ -309,4 +310,35 @@ describe Projects::CommitController do ...@@ -309,4 +310,35 @@ describe Projects::CommitController do
end end
end end
end end
describe 'GET pipelines' do
def get_pipelines(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project.to_param
}
get :pipelines, params.merge(extra_params)
end
context 'when the commit exists' do
context 'when the commit has one or more pipelines' do
it 'shows pipelines' do
get_pipelines(id: commit.id)
expect(response).to be_ok
end
end
end
context 'when the commit does not exist' do
before do
get_pipelines(id: 'e7a412c8da9f6d0081a633a4a402dde1c4694ebd')
end
it 'returns a 404' do
expect(response).to have_http_status(404)
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