Fixed tests. removed delegate to id

This commit is contained in:
Dmitriy Zaporozhets 2012-02-29 23:04:09 +02:00
parent bb164ebf1b
commit 25bde28d13
6 changed files with 27 additions and 13 deletions

View file

@ -2,17 +2,21 @@ require 'spec_helper'
describe Project, "Hooks" do
let(:project) { Factory :project }
before do
@key = Factory :key, :user => project.owner
@key_id = @key.identifier
end
describe "Post Receive Event" do
it "should create push event" do
oldrev, newrev, ref = '00000000000000000000000000000000', 'newrev', 'refs/heads/master'
project.observe_push(oldrev, newrev, ref)
project.observe_push(oldrev, newrev, ref, @key_id)
event = Event.last
event.should_not be_nil
event.project.should == project
event.action.should == Event::Pushed
event.data == project.web_hook_data(oldrev, newrev, ref)
event.data == project.web_hook_data(oldrev, newrev, ref, @key_id)
end
end
@ -20,7 +24,7 @@ describe Project, "Hooks" do
context "with no web hooks" do
it "raises no errors" do
lambda {
project.execute_web_hooks('oldrev', 'newrev', 'ref')
project.execute_web_hooks('oldrev', 'newrev', 'ref', @key_id)
}.should_not raise_error
end
end
@ -36,7 +40,7 @@ describe Project, "Hooks" do
@webhook.should_receive(:execute).once
@webhook_2.should_receive(:execute).once
project.execute_web_hooks('oldrev', 'newrev', 'refs/heads/master')
project.execute_web_hooks('oldrev', 'newrev', 'refs/heads/master', @key_id)
end
end
@ -48,12 +52,12 @@ describe Project, "Hooks" do
it "when pushing a branch for the first time" do
@webhook.should_not_receive(:execute)
project.execute_web_hooks('00000000000000000000000000000000', 'newrev', 'refs/heads/master')
project.execute_web_hooks('00000000000000000000000000000000', 'newrev', 'refs/heads/master', @key_id)
end
it "when pushing tags" do
@webhook.should_not_receive(:execute)
project.execute_web_hooks('oldrev', 'newrev', 'refs/tags/v1.0.0')
project.execute_web_hooks('oldrev', 'newrev', 'refs/tags/v1.0.0', @key_id)
end
end
@ -69,7 +73,7 @@ describe Project, "Hooks" do
# Fill nil/empty attributes
project.description = "This is a description"
@data = project.web_hook_data(@oldrev, @newrev, @ref)
@data = project.web_hook_data(@oldrev, @newrev, @ref, @key_id)
end
subject { @data }
@ -77,6 +81,8 @@ describe Project, "Hooks" do
it { should include(before: @oldrev) }
it { should include(after: @newrev) }
it { should include(ref: @ref) }
it { should include(user_id: project.owner.id) }
it { should include(user_name: project.owner.name) }
context "with repository data" do
subject { @data[:repository] }