Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
New feature: All builds page for admin user
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <[email protected]>
  • Loading branch information
dzaporozhets committed Oct 22, 2014
1 parent 96906f2 commit 0a4a1af
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ v5.1
- Add support for skip branches from build
- Add coverage parsing feature
- Update rails to 4.0.10
- All builds page for admin

v5.0.1
- Update rails to 4.0.5
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/admin/builds_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Admin::BuildsController < Admin::ApplicationController
before_filter :authenticate_user!

def index
@builds = Build.order('created_at DESC').page(params[:page]).per(30)
end
end
28 changes: 28 additions & 0 deletions app/views/admin/builds/_build.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%tr.build.alert{class: build_status_alert_class(build)}
%td.status
= build.status

%td.runner
- if build.runner
= link_to build.runner.id, admin_runner_path(build.runner)

%td.build-link
= link_to build_url(build) do
%strong #{build.short_sha}

%td.build-project
= truncate build.project.name, length: 30

%td.build-message
%span= truncate(build.git_commit_message, length: 50)

%td.build-branch
= build.ref

%td.duration
- if build.duration
#{distance_of_time_in_words build.duration}

%td.timestamp
- if build.finished_at
%span #{time_ago_in_words build.finished_at} ago
23 changes: 23 additions & 0 deletions app/views/admin/builds/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= content_for :title do
%h3.project-title
All builds

.pull-right
%small
= pluralize(@builds.total_count, 'build')

%table.builds
%thead
%tr
%th Status
%th Runner
%th Commit
%th Project
%th Message
%th Branch
%th Duration
%th Finished at

= render @builds

= paginate @builds
3 changes: 3 additions & 0 deletions app/views/layouts/_nav.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
%li
= link_to admin_projects_path do
Projects
%li
= link_to admin_builds_path do
Builds
%li
= link_to 'Help', help_path
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
resources :projects do
resources :runner_projects
end

resources :builds, only: :index
end

root :to => 'projects#index'
Expand Down
21 changes: 21 additions & 0 deletions spec/features/admin/builds_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

describe "Admin Builds" do
let(:project) { FactoryGirl.create :project }
let(:build) { FactoryGirl.create :build, project: project }

before do
skip_admin_auth
login_as :user
end

describe "GET /admin/builds" do
before do
build
visit admin_builds_path
end

it { page.should have_content "All builds" }
it { page.should have_content build.short_sha }
end
end

0 comments on commit 0a4a1af

Please sign in to comment.