Commit 08e21230 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'pending-tab' into 'master'

Add Pending Tab to Builds

## What does this MR do?

Add Pending Tab to Builds and separate "running" and "pending" jobs in UI.

## Why was this MR needed?

Increase visibility to "pending" .

## What are the relevant issue numbers?

Closes #19408 

## Screenshots

Before:
![Zrzut_ekranu_2016-07-05_o_11.52.48](/uploads/01dc1f3664f5aacb2ec09d52d19c521e/Zrzut_ekranu_2016-07-05_o_11.52.48.png)

After:
![Zrzut_ekranu_2016-07-05_o_11.51.34](/uploads/f3be02427996fecf50c65dd51ce1b9fb/Zrzut_ekranu_2016-07-05_o_11.51.34.png)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

cc @ubudzisz @yorickpeterse @grzesiek @tmaczukin @zj [@chastell](https://github.com/chastell) [@tomash](https://github.com/tomash)

See merge request !5084
parents c7569fb6 c9583054
...@@ -120,6 +120,7 @@ v 8.9.6 ...@@ -120,6 +120,7 @@ v 8.9.6
- Fix broken migration in MySQL. !5005 - Fix broken migration in MySQL. !5005
- Overwrite Host and X-Forwarded-Host headers in NGINX !5213 - Overwrite Host and X-Forwarded-Host headers in NGINX !5213
- Keeps issue number when importing from Gitlab.com - Keeps issue number when importing from Gitlab.com
- Add Pending tab for Builds (Katarzyna Kobierska, Urszula Budziszewska)
v 8.9.7 (unreleased) v 8.9.7 (unreleased)
- Fix import_data wrongly saved as a result of an invalid import_url - Fix import_data wrongly saved as a result of an invalid import_url
......
...@@ -5,8 +5,10 @@ class Admin::BuildsController < Admin::ApplicationController ...@@ -5,8 +5,10 @@ class Admin::BuildsController < Admin::ApplicationController
@builds = @all_builds.order('created_at DESC') @builds = @all_builds.order('created_at DESC')
@builds = @builds =
case @scope case @scope
when 'pending'
@builds.pending.reverse_order
when 'running' when 'running'
@builds.running_or_pending.reverse_order @builds.running.reverse_order
when 'finished' when 'finished'
@builds.finished @builds.finished
else else
......
...@@ -10,8 +10,10 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -10,8 +10,10 @@ class Projects::BuildsController < Projects::ApplicationController
@builds = @all_builds.order('created_at DESC') @builds = @all_builds.order('created_at DESC')
@builds = @builds =
case @scope case @scope
when 'pending'
@builds.pending.reverse_order
when 'running' when 'running'
@builds.running_or_pending.reverse_order @builds.running.reverse_order
when 'finished' when 'finished'
@builds.finished @builds.finished
else else
......
...@@ -10,15 +10,20 @@ ...@@ -10,15 +10,20 @@
All All
%span.badge.js-totalbuilds-count= @all_builds.count(:id) %span.badge.js-totalbuilds-count= @all_builds.count(:id)
%li{class: ('active' if @scope == 'pending')}
= link_to admin_builds_path(scope: :pending) do
Pending
%span.badge= number_with_delimiter(@all_builds.pending.count(:id))
%li{class: ('active' if @scope == 'running')} %li{class: ('active' if @scope == 'running')}
= link_to admin_builds_path(scope: :running) do = link_to admin_builds_path(scope: :running) do
Running Running
%span.badge.js-running-count= number_with_delimiter(@all_builds.running_or_pending.count(:id)) %span.badge= number_with_delimiter(@all_builds.running.count(:id))
%li{class: ('active' if @scope == 'finished')} %li{class: ('active' if @scope == 'finished')}
= link_to admin_builds_path(scope: :finished) do = link_to admin_builds_path(scope: :finished) do
Finished Finished
%span.badge.js-running-count= number_with_delimiter(@all_builds.finished.count(:id)) %span.badge= number_with_delimiter(@all_builds.finished.count(:id))
.nav-controls .nav-controls
- if @all_builds.running_or_pending.any? - if @all_builds.running_or_pending.any?
......
...@@ -11,17 +11,22 @@ ...@@ -11,17 +11,22 @@
%span.badge.js-totalbuilds-count %span.badge.js-totalbuilds-count
= number_with_delimiter(@all_builds.count(:id)) = number_with_delimiter(@all_builds.count(:id))
%li{class: ('active' if @scope == 'pending')}
= link_to project_builds_path(@project, scope: :pending) do
Pending
%span.badge
= number_with_delimiter(@all_builds.pending.count(:id))
%li{class: ('active' if @scope == 'running')} %li{class: ('active' if @scope == 'running')}
= link_to project_builds_path(@project, scope: :running) do = link_to project_builds_path(@project, scope: :running) do
Running Running
%span.badge.js-running-count %span.badge
= number_with_delimiter(@all_builds.running_or_pending.count(:id)) = number_with_delimiter(@all_builds.running.count(:id))
%li{class: ('active' if @scope == 'finished')} %li{class: ('active' if @scope == 'finished')}
= link_to project_builds_path(@project, scope: :finished) do = link_to project_builds_path(@project, scope: :finished) do
Finished Finished
%span.badge.js-running-count %span.badge
= number_with_delimiter(@all_builds.finished.count(:id)) = number_with_delimiter(@all_builds.finished.count(:id))
.nav-controls .nav-controls
......
...@@ -36,12 +36,45 @@ describe 'Admin Builds' do ...@@ -36,12 +36,45 @@ describe 'Admin Builds' do
end end
end end
context 'Pending tab' do
context 'when have pending builds' do
it 'shows pending builds' do
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
build2 = create(:ci_build, pipeline: pipeline, status: :running)
build3 = create(:ci_build, pipeline: pipeline, status: :success)
build4 = create(:ci_build, pipeline: pipeline, status: :failed)
visit admin_builds_path(scope: :pending)
expect(page).to have_selector('.nav-links li.active', text: 'Pending')
expect(page.find('.build-link')).to have_content(build1.id)
expect(page.find('.build-link')).not_to have_content(build2.id)
expect(page.find('.build-link')).not_to have_content(build3.id)
expect(page.find('.build-link')).not_to have_content(build4.id)
expect(page).to have_link 'Cancel all'
end
end
context 'when have no builds pending' do
it 'shows a message' do
create(:ci_build, pipeline: pipeline, status: :success)
visit admin_builds_path(scope: :pending)
expect(page).to have_selector('.nav-links li.active', text: 'Pending')
expect(page).to have_content 'No builds to show'
expect(page).not_to have_link 'Cancel all'
end
end
end
context 'Running tab' do context 'Running tab' do
context 'when have running builds' do context 'when have running builds' do
it 'shows running builds' do it 'shows running builds' do
build1 = create(:ci_build, pipeline: pipeline, status: :pending) build1 = create(:ci_build, pipeline: pipeline, status: :running)
build2 = create(:ci_build, pipeline: pipeline, status: :success) build2 = create(:ci_build, pipeline: pipeline, status: :success)
build3 = create(:ci_build, pipeline: pipeline, status: :failed) build3 = create(:ci_build, pipeline: pipeline, status: :failed)
build4 = create(:ci_build, pipeline: pipeline, status: :pending)
visit admin_builds_path(scope: :running) visit admin_builds_path(scope: :running)
...@@ -49,6 +82,7 @@ describe 'Admin Builds' do ...@@ -49,6 +82,7 @@ describe 'Admin Builds' do
expect(page.find('.build-link')).to have_content(build1.id) expect(page.find('.build-link')).to have_content(build1.id)
expect(page.find('.build-link')).not_to have_content(build2.id) expect(page.find('.build-link')).not_to have_content(build2.id)
expect(page.find('.build-link')).not_to have_content(build3.id) expect(page.find('.build-link')).not_to have_content(build3.id)
expect(page.find('.build-link')).not_to have_content(build4.id)
expect(page).to have_link 'Cancel all' expect(page).to have_link 'Cancel all'
end end
end end
......
...@@ -13,17 +13,33 @@ describe "Builds" do ...@@ -13,17 +13,33 @@ describe "Builds" do
end end
describe "GET /:project/builds" do describe "GET /:project/builds" do
context "Pending scope" do
before do
visit namespace_project_builds_path(@project.namespace, @project, scope: :pending)
end
it "shows Pending tab builds" do
expect(page).to have_link 'Cancel running'
expect(page).to have_selector('.nav-links li.active', text: 'Pending')
expect(page).to have_content @build.short_sha
expect(page).to have_content @build.ref
expect(page).to have_content @build.name
end
end
context "Running scope" do context "Running scope" do
before do before do
@build.run! @build.run!
visit namespace_project_builds_path(@project.namespace, @project, scope: :running) visit namespace_project_builds_path(@project.namespace, @project, scope: :running)
end end
it { expect(page).to have_selector('.nav-links li.active', text: 'Running') } it "shows Running tab builds" do
it { expect(page).to have_link 'Cancel running' } expect(page).to have_selector('.nav-links li.active', text: 'Running')
it { expect(page).to have_content @build.short_sha } expect(page).to have_link 'Cancel running'
it { expect(page).to have_content @build.ref } expect(page).to have_content @build.short_sha
it { expect(page).to have_content @build.name } expect(page).to have_content @build.ref
expect(page).to have_content @build.name
end
end end
context "Finished scope" do context "Finished scope" do
...@@ -32,9 +48,11 @@ describe "Builds" do ...@@ -32,9 +48,11 @@ describe "Builds" do
visit namespace_project_builds_path(@project.namespace, @project, scope: :finished) visit namespace_project_builds_path(@project.namespace, @project, scope: :finished)
end end
it { expect(page).to have_selector('.nav-links li.active', text: 'Finished') } it "shows Finished tab builds" do
it { expect(page).to have_content 'No builds to show' } expect(page).to have_selector('.nav-links li.active', text: 'Finished')
it { expect(page).to have_link 'Cancel running' } expect(page).to have_content 'No builds to show'
expect(page).to have_link 'Cancel running'
end
end end
context "All builds" do context "All builds" do
...@@ -43,11 +61,13 @@ describe "Builds" do ...@@ -43,11 +61,13 @@ describe "Builds" do
visit namespace_project_builds_path(@project.namespace, @project) visit namespace_project_builds_path(@project.namespace, @project)
end end
it { expect(page).to have_selector('.nav-links li.active', text: 'All') } it "shows All tab builds" do
it { expect(page).to have_content @build.short_sha } expect(page).to have_selector('.nav-links li.active', text: 'All')
it { expect(page).to have_content @build.ref } expect(page).to have_content @build.short_sha
it { expect(page).to have_content @build.name } expect(page).to have_content @build.ref
it { expect(page).not_to have_link 'Cancel running' } expect(page).to have_content @build.name
expect(page).not_to have_link 'Cancel running'
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