diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-04-24 14:54:16 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-04-24 14:54:16 +0300 |
commit | b98d2e9958d4c01ecf93c0abe44c51029033b3c1 (patch) | |
tree | 9f8035877fcce6277915ecd415b78b06d012dff2 | |
parent | 5939b18365c73401d5aeea25a83b935c6163bbf2 (diff) | |
download | gitlab-ci-b98d2e9958d4c01ecf93c0abe44c51029033b3c1.tar.gz |
Tabs Pending and Running on admin builds page
-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 |
3 files changed, 65 insertions, 0 deletions
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 |