Created
October 21, 2008 00:08
-
-
Save wycats/18218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.join(File.dirname(__FILE__), "spec_helper") | |
FileUtils.rm_rf(Merb.root / ".srcs") | |
describe "a POST to /ci/push" do | |
def request_push(user, name) | |
request("/ci/push", :method => "POST", | |
"CONTENT_TYPE" => "application/json", | |
:input => {:payload => {:repository => | |
{:name => name, :user => user, | |
:url => "git://github.com/wycats/merb.git"}}}.to_json) | |
end | |
it "raises a BadRequest if no payload is provided" do | |
request("/ci/push", :method => "POST").status.should == 400 | |
end | |
it "is forbidden when the repository is incorrect" do | |
resp = request_push("wycats", "merbz") | |
resp.status.should == 403 | |
end | |
it "is forbidden when the user is incorrect" do | |
resp = request_push("wycatz", "merb") | |
resp.status.should == 403 | |
end | |
describe "when the repository is correct" do | |
before(:all) do | |
@resp = request_push("wycats", "merb") | |
end | |
it "is successful" do | |
@resp.should be_successful | |
end | |
it "creates a .srcs directory" do | |
File.should be_directory(Dir.pwd / ".srcs") | |
end | |
it "creates a directory for the repository" do | |
File.should be_directory(Dir.pwd / ".srcs" / "merb") | |
end | |
it "runs git pull on the directory if it already exists" do | |
mtime = File.mtime(Dir.pwd / ".srcs" / "merb") | |
request_push("wycats", "merb") | |
File.mtime(Dir.pwd / ".srcs" / "merb").should == mtime | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment