summaryrefslogtreecommitdiff
path: root/spec/gitlab_post_receive_spec.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-07-03 11:00:18 -0400
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-07-03 11:00:18 -0400
commitc6ed2b058b5ab5fb435114491889676732aefcb2 (patch)
tree4cf184d4559cf0d7b10e8937c9fd93ee825de562 /spec/gitlab_post_receive_spec.rb
parent4539a066ecd2c5a16cab66f9e85f8f0ab747fc5f (diff)
downloadgitlab-shell-revert-gl-repository.tar.gz
Revert "Merge branch '86-follow-up-from-use-gl_repository-if-present-when-enqueing-sidekiq-postreceive-jobs' into 'master'"revert-gl-repository
This reverts commit fa6343515ba65423e9de4c98c6005facc6059938, reversing changes made to 62af7f6af72728cecb98c5275d8b7aeb3953e564.
Diffstat (limited to 'spec/gitlab_post_receive_spec.rb')
-rw-r--r--spec/gitlab_post_receive_spec.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb
index 7cebf29..69e19e6 100644
--- a/spec/gitlab_post_receive_spec.rb
+++ b/spec/gitlab_post_receive_spec.rb
@@ -19,7 +19,7 @@ describe GitlabPostReceive do
before do
GitlabConfig.any_instance.stub(repos_path: repository_path)
GitlabNet.any_instance.stub(broadcast_message: { })
- GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, wrongly_encoded_changes) { [] }
+ GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, repo_path, wrongly_encoded_changes) { [] }
GitlabNet.any_instance.stub(notify_post_receive: true)
expect(Time).to receive(:now).and_return(enqueued_at)
end
@@ -37,7 +37,7 @@ describe GitlabPostReceive do
context 'Without broad cast message' do
context 'pushing new branch' do
before do
- GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, wrongly_encoded_changes) do
+ GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, repo_path, wrongly_encoded_changes) do
[{
"branch_name" => "new_branch",
"url" => "http://localhost/dzaporozhets/gitlab-ci/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch",
@@ -64,7 +64,7 @@ describe GitlabPostReceive do
context 'pushing existing branch with merge request created' do
before do
- GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, wrongly_encoded_changes) do
+ GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, repo_path, wrongly_encoded_changes) do
[{
"branch_name" => "feature_branch",
"url" => "http://localhost/dzaporozhets/gitlab-ci/merge_requests/1",
@@ -92,7 +92,7 @@ describe GitlabPostReceive do
context 'show broadcast message and merge request link' do
before do
- GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, wrongly_encoded_changes) do
+ GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, repo_path, wrongly_encoded_changes) do
[{
"branch_name" => "new_branch",
"url" => "http://localhost/dzaporozhets/gitlab-ci/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch",
@@ -146,6 +146,19 @@ describe GitlabPostReceive do
gitlab_post_receive.exec
end
+
+ context 'when gl_repository is nil' do
+ let(:gl_repository) { nil }
+
+ it "pushes a Sidekiq job with the repository path" do
+ expect(redis_client).to receive(:rpush).with(
+ 'resque:gitlab:queue:post_receive',
+ %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}","enqueued_at":#{enqueued_at.to_f}}/
+ ).and_return(true)
+
+ gitlab_post_receive.exec
+ end
+ end
end
context 'reference counter' do
@@ -179,7 +192,7 @@ describe GitlabPostReceive do
context 'post_receive notification' do
it 'calls the api to notify the execution of the hook' do
expect_any_instance_of(GitlabNet).to receive(:notify_post_receive).
- with(gl_repository)
+ with(gl_repository, repo_path)
gitlab_post_receive.exec
end