Skip to content

Commit

Permalink
display github url in app
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Nov 12, 2008
1 parent 1f12307 commit e0948df
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app.rb
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions lib/integrity/build.rb
Expand Up @@ -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])
Expand Down
15 changes: 15 additions & 0 deletions spec/app_spec.rb
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down

0 comments on commit e0948df

Please sign in to comment.