summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/builds/show.html.haml4
-rw-r--r--app/views/charts/_build_times.haml2
-rw-r--r--lib/charts.rb6
-rw-r--r--spec/features/projects_spec.rb12
-rw-r--r--spec/models/build_spec.rb53
5 files changed, 33 insertions, 44 deletions
diff --git a/app/views/builds/show.html.haml b/app/views/builds/show.html.haml
index 6db825c..d664641 100644
--- a/app/views/builds/show.html.haml
+++ b/app/views/builds/show.html.haml
@@ -51,10 +51,10 @@
- else
= link_to "Retry", retry_project_build_path(@project, @build.sha), class: 'btn btn-sm btn-primary', method: :post
- - if @build.started_at
+ - if @build.duration
%p
%span.attr-name Duration:
- #{build_duration @build}
+ #{distance_of_time_in_words @build.duration}
%p
%span.attr-name Created:
#{time_ago_in_words(@build.created_at)} ago
diff --git a/app/views/charts/_build_times.haml b/app/views/charts/_build_times.haml
index 97359a5..579556d 100644
--- a/app/views/charts/_build_times.haml
+++ b/app/views/charts/_build_times.haml
@@ -2,7 +2,7 @@
%legend
Build duration in seconds for last 30 builds
- %canvas#build_timesChart.padded{width: 800, height: 200}
+ %canvas#build_timesChart.padded{width: 800, height: 300}
:javascript
var data = {
diff --git a/lib/charts.rb b/lib/charts.rb
index 17db2f9..f9f1615 100644
--- a/lib/charts.rb
+++ b/lib/charts.rb
@@ -55,10 +55,10 @@ module Charts
class BuildTime < Chart
def collect
- @labels = (1..30).to_a
builds = project.builds.order(:finished_at).limit(30)
- @build_times = builds.map do |build|
- build.duration
+ builds.each do |build|
+ @labels << build.short_sha
+ @build_times << build.duration
end
end
end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 227212c..a66b6ba 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -35,22 +35,14 @@ describe "Projects" do
describe "GET /projects/:id/charts" do
before do
- visit project_chart_path(@project, 'build_times')
- end
-
- it { page.should have_content 'Overall' }
- it { page.should have_content 'Build duration in seconds for last 30 builds' }
- end
-
- describe "GET /projects/:id/charts/builds" do
- before do
- visit project_chart_path(@project, 'builds')
+ visit project_charts_path(@project)
end
it { page.should have_content 'Overall' }
it { page.should have_content 'Builds chart for last week' }
it { page.should have_content 'Builds chart for last month' }
it { page.should have_content 'Builds chart for last year' }
+ it { page.should have_content 'Build duration in seconds for last 30 builds' }
end
describe "GET /projects/:id/details" do
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 17c3ba5..32a0446 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -50,60 +50,57 @@ describe Build do
build.ci_skip?.should == false
end
end
-
+
describe '#project_recipients' do
context 'always sending notification' do
it 'should return git_author_email as only recipient when no additional recipients are given' do
- project = FactoryGirl.create :project,
- email_add_committer: true,
- email_recipients: ''
- build = FactoryGirl.create :build,
- status: :success,
- project: project
+ project = FactoryGirl.create :project,
+ email_add_committer: true,
+ email_recipients: ''
+ build = FactoryGirl.create :build,
+ status: :success,
+ project: project
expected = 'git_author_email'
build.stub(:git_author_email) { expected }
build.project_recipients.should == [expected]
end
it 'should return git_author_email and additional recipients' do
- project = FactoryGirl.create :project,
- email_add_committer: true,
- email_recipients: 'rec1 rec2'
- build = FactoryGirl.create :build,
- status: :success,
- project: project
+ project = FactoryGirl.create :project,
+ email_add_committer: true,
+ email_recipients: 'rec1 rec2'
+ build = FactoryGirl.create :build,
+ status: :success,
+ project: project
expected = 'git_author_email'
build.stub(:git_author_email) { expected }
build.project_recipients.should == ['rec1', 'rec2', expected]
end
it 'should return recipients' do
- project = FactoryGirl.create :project,
- email_add_committer: false,
- email_recipients: 'rec1 rec2'
- build = FactoryGirl.create :build,
- status: :success,
- project: project
+ project = FactoryGirl.create :project,
+ email_add_committer: false,
+ email_recipients: 'rec1 rec2'
+ build = FactoryGirl.create :build,
+ status: :success,
+ project: project
expected = 'git_author_email'
build.stub(:git_author_email) { expected }
build.project_recipients.should == ['rec1', 'rec2']
end
it 'should return unique recipients only' do
- project = FactoryGirl.create :project,
- email_add_committer: true,
- email_recipients: 'rec1 rec1 rec2'
- build = FactoryGirl.create :build,
- status: :success,
- project: project
+ project = FactoryGirl.create :project,
+ email_add_committer: true,
+ email_recipients: 'rec1 rec1 rec2'
+ build = FactoryGirl.create :build,
+ status: :success,
+ project: project
expected = 'rec2'
build.stub(:git_author_email) { expected }
build.project_recipients.should == ['rec1', 'rec2']
end
end
end
-
end
-
-