summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-02-29 23:04:09 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-02-29 23:04:09 +0200
commit25bde28d13cdffda8efa4ecae00985085e6aa565 (patch)
tree61c676f45e05b4b2e3a7dd6b0b3196486d481f32 /spec
parentbb164ebf1bd672527a76a6699427cbec728d638b (diff)
downloadgitlab-ce-25bde28d13cdffda8efa4ecae00985085e6aa565.tar.gz
Fixed tests. removed delegate to id
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_hooks_spec.rb20
-rw-r--r--spec/workers/post_receive_spec.rb11
2 files changed, 21 insertions, 10 deletions
diff --git a/spec/models/project_hooks_spec.rb b/spec/models/project_hooks_spec.rb
index 841c85ba803..5a03b01f80b 100644
--- a/spec/models/project_hooks_spec.rb
+++ b/spec/models/project_hooks_spec.rb
@@ -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] }
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index 500a69982c7..c28273d5e81 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -10,17 +10,22 @@ describe PostReceive do
context "web hooks" do
let(:project) { Factory :project }
+ before do
+ @key = Factory :key, :user => project.owner
+ @key_id = @key.identifier
+ end
it "it retrieves the correct project" do
Project.should_receive(:find_by_path).with(project.path)
- PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master')
+ Key.should_receive(:find_by_identifier).with(project.path)
+ PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', @key_id)
end
it "asks the project to execute web hooks" do
Project.stub(find_by_path: project)
- project.should_receive(:execute_web_hooks).with('sha-old', 'sha-new', 'refs/heads/master')
+ project.should_receive(:execute_web_hooks).with('sha-old', 'sha-new', 'refs/heads/master', @key_id)
- PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master')
+ PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', @key_id)
end
end
end