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

Commit 0a4a1af

Browse files
committed
New feature: All builds page for admin user
Signed-off-by: Dmitriy Zaporozhets <[email protected]>
1 parent 96906f2 commit 0a4a1af

File tree

7 files changed

+85
-0
lines changed

7 files changed

+85
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v5.1
55
- Add support for skip branches from build
66
- Add coverage parsing feature
77
- Update rails to 4.0.10
8+
- All builds page for admin
89

910
v5.0.1
1011
- Update rails to 4.0.5
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Admin::BuildsController < Admin::ApplicationController
2+
before_filter :authenticate_user!
3+
4+
def index
5+
@builds = Build.order('created_at DESC').page(params[:page]).per(30)
6+
end
7+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
%tr.build.alert{class: build_status_alert_class(build)}
2+
%td.status
3+
= build.status
4+
5+
%td.runner
6+
- if build.runner
7+
= link_to build.runner.id, admin_runner_path(build.runner)
8+
9+
%td.build-link
10+
= link_to build_url(build) do
11+
%strong #{build.short_sha}
12+
13+
%td.build-project
14+
= truncate build.project.name, length: 30
15+
16+
%td.build-message
17+
%span= truncate(build.git_commit_message, length: 50)
18+
19+
%td.build-branch
20+
= build.ref
21+
22+
%td.duration
23+
- if build.duration
24+
#{distance_of_time_in_words build.duration}
25+
26+
%td.timestamp
27+
- if build.finished_at
28+
%span #{time_ago_in_words build.finished_at} ago
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
= content_for :title do
2+
%h3.project-title
3+
All builds
4+
5+
.pull-right
6+
%small
7+
= pluralize(@builds.total_count, 'build')
8+
9+
%table.builds
10+
%thead
11+
%tr
12+
%th Status
13+
%th Runner
14+
%th Commit
15+
%th Project
16+
%th Message
17+
%th Branch
18+
%th Duration
19+
%th Finished at
20+
21+
= render @builds
22+
23+
= paginate @builds

app/views/layouts/_nav.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
%li
1717
= link_to admin_projects_path do
1818
Projects
19+
%li
20+
= link_to admin_builds_path do
21+
Builds
1922
%li
2023
= link_to 'Help', help_path
2124

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
resources :projects do
4949
resources :runner_projects
5050
end
51+
52+
resources :builds, only: :index
5153
end
5254

5355
root :to => 'projects#index'

spec/features/admin/builds_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'spec_helper'
2+
3+
describe "Admin Builds" do
4+
let(:project) { FactoryGirl.create :project }
5+
let(:build) { FactoryGirl.create :build, project: project }
6+
7+
before do
8+
skip_admin_auth
9+
login_as :user
10+
end
11+
12+
describe "GET /admin/builds" do
13+
before do
14+
build
15+
visit admin_builds_path
16+
end
17+
18+
it { page.should have_content "All builds" }
19+
it { page.should have_content build.short_sha }
20+
end
21+
end

0 commit comments

Comments
 (0)