diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/gitlab_net_spec.rb | 18 | ||||
-rw-r--r-- | spec/gitlab_post_receive_spec.rb | 23 | ||||
-rw-r--r-- | spec/vcr_cassettes/notify-post-receive.yml | 2 |
3 files changed, 11 insertions, 32 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb index f3c67fd..eb2dd12 100644 --- a/spec/gitlab_net_spec.rb +++ b/spec/gitlab_net_spec.rb @@ -97,20 +97,13 @@ describe GitlabNet, vcr: true do describe :merge_request_urls do let(:gl_repository) { "project-1" } - let(:repo_path) { "/path/to/my/repo.git" } let(:changes) { "123456 789012 refs/heads/test\n654321 210987 refs/tags/tag" } let(:encoded_changes) { "123456%20789012%20refs/heads/test%0A654321%20210987%20refs/tags/tag" } it "sends the given arguments as encoded URL parameters" do - gitlab_net.should_receive(:get).with("#{host}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}&gl_repository=#{gl_repository}") + gitlab_net.should_receive(:get).with("#{host}/merge_request_urls?gl_repository=#{gl_repository}&changes=#{encoded_changes}") - gitlab_net.merge_request_urls(gl_repository, repo_path, changes) - end - - it "omits the gl_repository parameter if it's nil" do - gitlab_net.should_receive(:get).with("#{host}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}") - - gitlab_net.merge_request_urls(nil, repo_path, changes) + gitlab_net.merge_request_urls(gl_repository, changes) end end @@ -165,21 +158,20 @@ describe GitlabNet, vcr: true do describe '#notify_post_receive' do let(:gl_repository) { 'project-1' } - let(:repo_path) { '/path/to/my/repo.git' } let(:params) do - { gl_repository: gl_repository, project: repo_path } + { gl_repository: gl_repository } end it 'sets the arguments as form parameters' do VCR.use_cassette('notify-post-receive') do Net::HTTP::Post.any_instance.should_receive(:set_form_data).with(hash_including(params)) - gitlab_net.notify_post_receive(gl_repository, repo_path) + gitlab_net.notify_post_receive(gl_repository) end end it 'returns true if notification was succesful' do VCR.use_cassette('notify-post-receive') do - expect(gitlab_net.notify_post_receive(gl_repository, repo_path)).to be_true + expect(gitlab_net.notify_post_receive(gl_repository)).to be_true end end end diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb index 69e19e6..7cebf29 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, repo_path, wrongly_encoded_changes) { [] } + GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, 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, repo_path, wrongly_encoded_changes) do + GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, 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, repo_path, wrongly_encoded_changes) do + GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, 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, repo_path, wrongly_encoded_changes) do + GitlabNet.any_instance.stub(:merge_request_urls).with(gl_repository, 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,19 +146,6 @@ 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 @@ -192,7 +179,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, repo_path) + with(gl_repository) gitlab_post_receive.exec end diff --git a/spec/vcr_cassettes/notify-post-receive.yml b/spec/vcr_cassettes/notify-post-receive.yml index 255f415..b007339 100644 --- a/spec/vcr_cassettes/notify-post-receive.yml +++ b/spec/vcr_cassettes/notify-post-receive.yml @@ -41,6 +41,6 @@ http_interactions: body: encoding: UTF-8 string: '200' - http_version: + http_version: recorded_at: Wed, 21 Jun 2017 12:47:48 GMT recorded_with: VCR 2.4.0 |