Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:rubygems/gem-testers

Conflicts:
	app/controllers/versions_controller.rb
  • Loading branch information...
commit 1cd23c0be794636b71171b495af37eee0d8b33ad 2 parents 020d0bf + dfdf9a8
Erik Hollensbe authored
View
2  app/controllers/rubygems_controller.rb
@@ -22,7 +22,7 @@ def show
@platform = params[:platform] unless params[:platform].blank?
respond_to do |format|
- format.json { render json: (@rubygem.nil? ? {} : @rubygem.to_json(include: { versions: {include: :test_results} } )) }
+ format.json { render json: (@rubygem.nil? ? {} : @rubygem.to_json(methods: [:pass_count, :fail_count], include: { versions: {methods: [:pass_count, :fail_count], include: :test_results} } )) }
format.html do
if @rubygem
@paged_source = rubygem_paged_path(@rubygem.name, %q[json])
View
8 app/controllers/versions_controller.rb
@@ -31,8 +31,11 @@ def show
respond_to do |format|
format.json do
- render json: @version, include: :test_results if not @version.nil?
- render json: {} if @version.nil?
+ if @version.nil?
+ render json: {}
+ else
+ render json: @version, include: [:test_results], methods: [:pass_count, :fail_count]
+ end
end
format.html do
@@ -60,6 +63,5 @@ def show
end
end
end
-
end
View
8 app/models/rubygem.rb
@@ -10,4 +10,12 @@ class Rubygem < ActiveRecord::Base
has_many :test_results
has_many :versions
+ def pass_count
+ TestResult.where(result: true, rubygem_id: self.id).count
+ end
+
+ def fail_count
+ TestResult.where(result: false, rubygem_id: self.id).count
+ end
+
end
View
8 app/models/version.rb
@@ -11,4 +11,12 @@ def check_prerelease
self.prerelease = false if self.prerelease.nil?
not self.prerelease.nil?
end
+
+ def pass_count
+ TestResult.where(result: true, version_id: self.id).count
+ end
+
+ def fail_count
+ TestResult.where(result: false, version_id: self.id).count
+ end
end
View
2  app/views/layouts/application.html.haml
@@ -16,7 +16,7 @@
%body
#topnav
%a{:href => root_path} Gem Testers
- %div Tests run everywhere are collected here.
+ %div Tests run everywhere, collected here.
#wrapper
.info
.flash=flash[:notice]
View
3  app/views/test_results/show.html.haml
@@ -42,9 +42,12 @@
= render :partial => 'shared/test_result', :object => @result
.border.no-padding
.background.no-padding
+ .time
+ Submitted on #{@result.created_at.strftime('%m/%d/%Y at %I:%M%p %Z').downcase }
.button-wrapper
%button#button
Select All
+ %br.clear-both
#textbox
%textarea
= filter_ansi @result.test_output
View
10 public/stylesheets/screen.css
@@ -308,6 +308,14 @@ input#rubygems {
height: 100%;
}
+.time {
+ float: left;
+ padding: 7px;
+}
.button-wrapper {
- text-align: right
+ float: right;
+}
+
+.clear-both {
+ clear: both;
}
View
3  spec/controllers/rubygems_controller_spec.rb
@@ -32,8 +32,7 @@
get :show, id: @g.name, format: 'json'
response.should be_success
- response.body.should == @g.to_json(include: { versions: {include: :test_results} } )
-
+ response.body.should == @g.to_json(methods: [:pass_count, :fail_count], include: { versions: {methods: [:pass_count, :fail_count], include: :test_results} } )
end
it 'should be successful when the rubygem is not found' do
View
2  spec/controllers/versions_controller_spec.rb
@@ -44,7 +44,7 @@
it 'should respond to json format' do
get :show, rubygem_id: @r.name, id: @v.number + '.json'
- response.body.should == @v.to_json(include: :test_results)
+ response.body.should == @v.to_json(methods: [:pass_count, :fail_count], include: :test_results)
end
it 'should #show successfully' do
View
16 spec/models/rubygem_spec.rb
@@ -27,4 +27,20 @@
g.save.should be_false
end
end
+
+ it 'should count passes' do
+ g = Factory.create :rubygem
+ Factory.create :test_result, rubygem: g, result: true
+ 2.times { Factory.create :test_result, rubygem: g, result: false }
+
+ g.pass_count.should == 1
+ end
+
+ it 'should count failures' do
+ g = Factory.create :rubygem
+ Factory.create :test_result, rubygem: g, result: true
+ 2.times { Factory.create :test_result, rubygem: g, result: false }
+
+ g.fail_count.should == 2
+ end
end
View
14 spec/models/version_spec.rb
@@ -63,4 +63,18 @@
v = Factory.build :version, rubygem: nil
v.save.should be_false
end
+
+ it 'should count passes' do
+ v = Factory.create :version, rubygem: @gem
+ 3.times { Factory.create :test_result, version: v, rubygem: @gem, result: true }
+ 2.times { Factory.create :test_result, version: v, rubygem: @gem, result: false }
+ v.pass_count.should == 3
+ end
+
+ it 'should count failures' do
+ v = Factory.create :version, rubygem: @gem
+ 1.times { Factory.create :test_result, version: v, rubygem: @gem, result: true }
+ 2.times { Factory.create :test_result, version: v, rubygem: @gem, result: false }
+ v.fail_count.should == 2
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.