Permalink
Browse files

display github url in app

  • Loading branch information...
1 parent 1f12307 commit e0948df3bac649829bc64df7f72ac3d73d7c9184 @sr sr committed Nov 12, 2008
Showing with 29 additions and 1 deletion.
  1. +8 −0 app.rb
  2. +4 −0 lib/integrity/build.rb
  3. +15 −0 spec/app_spec.rb
  4. +1 −0 spec/spec_helper.rb
  5. +1 −1 views/build_info.haml
View
8 app.rb
@@ -196,6 +196,14 @@ def build_url(build)
"/#{build.project.permalink}/builds/#{build.commit_identifier}"
end
+ def commit_url(build)
+ if url = build.commit_github_url
+ %Q(<a href="#{url}">#{build.short_commit_identifier}</a>)
+ else
+ build.short_commit_identifier
+ end
+ end
+
def filter_attributes_of(model)
valid = model.properties.collect {|p| p.name.to_s }
Hash[*params.dup.select {|k,_| valid.include?(k) }.flatten]
View
4 lib/integrity/build.rb
@@ -41,6 +41,10 @@ def commit_message
commit_metadata[:message]
end
+ def commit_github_url
+ commit_metadata[:github_commit_uri]
+ end
+
def commited_at
case commit_metadata[:date]
when String then Time.parse(commit_metadata[:date])
View
15 spec/app_spec.rb
@@ -787,6 +787,21 @@ def do_get
end
end
+ describe '#commit_url' do
+ it 'should return the short identifier of the commit if cant get an URI' do
+ @context.commit_url(mock_build).should == '9f6302'
+ end
+
+ it 'should return a link to the commit' do
+ build = mock_build
+ build.stub!(:commit_github_url).
+ and_return("http://github.com/foca/integrity/commit/#{build.commit_identifier}")
+ @context.commit_url(build).should ==
+ %Q(<a href="http://github.com/foca/integrity/commit/#{build.commit_identifier}">\
+#{build.short_commit_identifier}</a>)
+ end
+ end
+
describe "#filter_attributes_of" do
before do
@context.stub!(:params).and_return("some" => "arguments", "are" => "better", "left" => "unspoken")
View
1 spec/spec_helper.rb
@@ -115,6 +115,7 @@ def mock_build(messages={})
:output => 'output',
:project => @project,
:commit_identifier => '9f6302002d2259c05a64767e0dedb15d280a4848',
+ :commit_github_url => nil,
:commit_author => mock("author",
:name => 'Nicolás Sanguinetti',
:email => 'contacto@nicolassanguinetti.info',
View
2 views/build_info.haml
@@ -1,6 +1,6 @@
%h1
Built
- &= @build.short_commit_identifier
+ = commit_url(@build)
= @build.successful? ? "successfully" : "and failed"
%blockquote
%p&= @build.commit_message

0 comments on commit e0948df

Please sign in to comment.