diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-24 11:59:32 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-24 11:59:32 +0000 |
commit | 0783a65989b2a99122fc78b578e583e775975399 (patch) | |
tree | 2b57de9c0df91c483748821fb6639a24e83c7ea7 | |
parent | 38f834f3537bf51a9ea4ba9c2d85ed55f8bb86b6 (diff) | |
parent | 234b3050bd7ba609f292a27adfe628996c1a6480 (diff) | |
download | gitlab-ci-0783a65989b2a99122fc78b578e583e775975399.tar.gz |
Merge branch 'builds_tabs' into 'master'
Pending and Running tabs on admin builds page
https://dev.gitlab.org/gitlab/gitlab-ci/issues/212
See merge request !81
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/admin/builds_controller.rb | 5 | ||||
-rw-r--r-- | app/views/admin/builds/index.html.haml | 11 | ||||
-rw-r--r-- | spec/features/admin/builds_spec.rb | 49 |
4 files changed, 66 insertions, 0 deletions
@@ -2,6 +2,7 @@ v7.11.0 - Deploy Jobs API calls - Projects search on dashboard page - Improved runners page + - Running and Pending tabs on admin builds page v7.10.0 - Projects sorting by last commit date diff --git a/app/controllers/admin/builds_controller.rb b/app/controllers/admin/builds_controller.rb index bc6bd8f..64f9da2 100644 --- a/app/controllers/admin/builds_controller.rb +++ b/app/controllers/admin/builds_controller.rb @@ -1,5 +1,10 @@ class Admin::BuildsController < Admin::ApplicationController def index + @scope = params[:scope] @builds = Build.order('created_at DESC').page(params[:page]).per(30) + + if ["pending", "running"].include? @scope + @builds = @builds.send(@scope) + end end end diff --git a/app/views/admin/builds/index.html.haml b/app/views/admin/builds/index.html.haml index 5f1f489..3db680e 100644 --- a/app/views/admin/builds/index.html.haml +++ b/app/views/admin/builds/index.html.haml @@ -6,6 +6,17 @@ %small = pluralize(@builds.total_count, 'build') +%ul.nav.nav-tabs.append-bottom-20 + %li{class: ("active" if @scope.nil?)} + = link_to 'All builds', admin_builds_path + + %li{class: ("active" if @scope == "pending")} + = link_to "Pending", admin_builds_path(scope: :pending) + + %li{class: ("active" if @scope == "running")} + = link_to "Running", admin_builds_path(scope: :running) + + %table.builds %thead %tr diff --git a/spec/features/admin/builds_spec.rb b/spec/features/admin/builds_spec.rb index a082b81..e62e836 100644 --- a/spec/features/admin/builds_spec.rb +++ b/spec/features/admin/builds_spec.rb @@ -19,4 +19,53 @@ describe "Admin Builds" do it { page.should have_content "All builds" } it { page.should have_content build.short_sha } end + + describe "Tabs" do + it "shows all builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + page.all(".build-link").size.should == 4 + end + + it "shows pending builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".nav.nav-tabs" do + click_on "Pending" + end + + page.find(".build-link").should have_content(build.id) + page.find(".build-link").should_not have_content(build1.id) + page.find(".build-link").should_not have_content(build2.id) + page.find(".build-link").should_not have_content(build3.id) + end + + it "shows running builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".nav.nav-tabs" do + click_on "Running" + end + + page.find(".build-link").should have_content(build1.id) + page.find(".build-link").should_not have_content(build.id) + page.find(".build-link").should_not have_content(build2.id) + page.find(".build-link").should_not have_content(build3.id) + end + end end |