2011-12-14 17:38:52 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PostReceive do
|
|
|
|
|
|
|
|
context "as a resque worker" do
|
|
|
|
it "reponds to #perform" do
|
|
|
|
PostReceive.should respond_to(:perform)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "web hooks" do
|
|
|
|
let(:project) { Factory :project }
|
2012-02-29 22:04:09 +01:00
|
|
|
before do
|
|
|
|
@key = Factory :key, :user => project.owner
|
|
|
|
@key_id = @key.identifier
|
|
|
|
end
|
2011-12-14 17:38:52 +01:00
|
|
|
|
|
|
|
it "it retrieves the correct project" do
|
|
|
|
Project.should_receive(:find_by_path).with(project.path)
|
2012-02-29 22:04:09 +01:00
|
|
|
Key.should_receive(:find_by_identifier).with(project.path)
|
|
|
|
PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', @key_id)
|
2011-12-14 17:38:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "asks the project to execute web hooks" do
|
|
|
|
Project.stub(find_by_path: project)
|
2012-02-29 22:04:09 +01:00
|
|
|
project.should_receive(:execute_web_hooks).with('sha-old', 'sha-new', 'refs/heads/master', @key_id)
|
2011-12-14 17:38:52 +01:00
|
|
|
|
2012-02-29 22:04:09 +01:00
|
|
|
PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', @key_id)
|
2011-12-14 17:38:52 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|