Skip to content

Commit

Permalink
display full push uri [integrity#34]
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Oct 29, 2008
1 parent d4695c6 commit 5cecadf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/integrity/ui.rb
Expand Up @@ -186,6 +186,10 @@ def project_url(project, *path)
"/" << [project.permalink, *path].join("/")
end

def push_url_for(project)
Addressable::URI.parse(Integrity.config[:base_uri]).join("#{project_url(project)}/push").to_s
end

def build_url(build)
"/#{build.project.permalink}/builds/#{build.commit_identifier}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/integrity/ui/views/new.haml
Expand Up @@ -41,7 +41,7 @@
%h2 Push URL
%p
You can use this Push URL with your GitHub project to enable automated continuous integration
%input.text#push_url{ :name => "push_url", :type => "text", :value => project_url(@project, :push), :disabled => :disabled }
%input.text#push_url{ :name => "push_url", :type => "text", :value => push_url_for(@project), :disabled => :disabled }

%form{ :method => "post", :action => project_url(@project) }
.hidden
Expand Down
20 changes: 17 additions & 3 deletions spec/ui_spec.rb
Expand Up @@ -203,7 +203,10 @@ def enable_basic_auth!
end

describe "POST /" do
before { Project.stub!(:new).and_return(mock_project) }
before do
Integrity.stub!(:config).and_return(:base_uri => 'http://foo.org')
Project.stub!(:new).and_return(mock_project)
end

it "should re-render the 'new' view when the project has invalid attributes" do
mock_project.stub!(:save).and_return(false)
Expand Down Expand Up @@ -356,7 +359,10 @@ def enable_basic_auth!
end

describe "GET /:project/edit" do
before { Project.stub!(:first).with(:permalink => "integrity").and_return mock_project }
before do
Integrity.stub!(:config).and_return(:base_uri => 'http://foo.org')
Project.stub!(:first).with(:permalink => "integrity").and_return mock_project
end

it "should be success" do
get_it "/integrity/edit"
Expand Down Expand Up @@ -391,12 +397,13 @@ def enable_basic_auth!
it 'should display the push URL' do
get_it '/integrity/edit'
body.should have_tag('h2', 'Push URL')
body.should have_tag('input#push_url[@value="/integrity/push"]')
body.should have_tag('input#push_url[@value="http://foo.org/integrity/push"]')
end
end

describe "PUT /:project" do
before do
Integrity.stub!(:config).and_return(:base_uri => 'http://foo.org')
Project.stub!(:first).with(:permalink => "integrity").and_return mock_project
end

Expand Down Expand Up @@ -804,6 +811,13 @@ def do_get
end
end

describe '#push_url_for' do
it 'should receive a project and return its github push url using :base_uri option' do
Integrity.config.should_receive(:[]).with(:base_uri).and_return('http://foo.org')
@context.push_url_for(mock_project).should == 'http://foo.org/integrity/push'
end
end

describe '#build_url' do
before(:each) do
@build = mock_build(
Expand Down

0 comments on commit 5cecadf

Please sign in to comment.