diff options
author | Stan Hu <stanhu@gmail.com> | 2017-05-23 21:18:26 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-05-24 04:26:30 +0000 |
commit | f50598f704817115927ea478bd1a4138bd66edb5 (patch) | |
tree | f19c54480bbdb0d4e5be839659074eb3ac5c5bfe /spec | |
parent | dae8838057114bb76c73acf050a5053024f724cb (diff) | |
download | gitlab-ce-f50598f704817115927ea478bd1a4138bd66edb5.tar.gz |
Merge branch 'fix-notify-post-receive' into 'master'
Prevent errors from non-functional notify_post_receive endpoint
See merge request !11509
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/internal_spec.rb | 161 |
1 files changed, 81 insertions, 80 deletions
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 2ceb4648ece..cf232e7ff69 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -466,86 +466,87 @@ describe API::Internal do end end - describe 'POST /notify_post_receive' do - let(:valid_params) do - { project: project.repository.path, secret_token: secret_token } - end - - let(:valid_wiki_params) do - { project: project.wiki.repository.path, secret_token: secret_token } - end - - before do - allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) - end - - it "calls the Gitaly client with the project's repository" do - expect(Gitlab::GitalyClient::Notifications). - to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)). - and_call_original - expect_any_instance_of(Gitlab::GitalyClient::Notifications). - to receive(:post_receive) - - post api("/internal/notify_post_receive"), valid_params - - expect(response).to have_http_status(200) - end - - it "calls the Gitaly client with the wiki's repository if it's a wiki" do - expect(Gitlab::GitalyClient::Notifications). - to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)). - and_call_original - expect_any_instance_of(Gitlab::GitalyClient::Notifications). - to receive(:post_receive) - - post api("/internal/notify_post_receive"), valid_wiki_params - - expect(response).to have_http_status(200) - end - - it "returns 500 if the gitaly call fails" do - expect_any_instance_of(Gitlab::GitalyClient::Notifications). - to receive(:post_receive).and_raise(GRPC::Unavailable) - - post api("/internal/notify_post_receive"), valid_params - - expect(response).to have_http_status(500) - end - - context 'with a gl_repository parameter' do - let(:valid_params) do - { gl_repository: "project-#{project.id}", secret_token: secret_token } - end - - let(:valid_wiki_params) do - { gl_repository: "wiki-#{project.id}", secret_token: secret_token } - end - - it "calls the Gitaly client with the project's repository" do - expect(Gitlab::GitalyClient::Notifications). - to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)). - and_call_original - expect_any_instance_of(Gitlab::GitalyClient::Notifications). - to receive(:post_receive) - - post api("/internal/notify_post_receive"), valid_params - - expect(response).to have_http_status(200) - end - - it "calls the Gitaly client with the wiki's repository if it's a wiki" do - expect(Gitlab::GitalyClient::Notifications). - to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)). - and_call_original - expect_any_instance_of(Gitlab::GitalyClient::Notifications). - to receive(:post_receive) - - post api("/internal/notify_post_receive"), valid_wiki_params - - expect(response).to have_http_status(200) - end - end - end + # TODO: Uncomment when the end-point is reenabled + # describe 'POST /notify_post_receive' do + # let(:valid_params) do + # { project: project.repository.path, secret_token: secret_token } + # end + # + # let(:valid_wiki_params) do + # { project: project.wiki.repository.path, secret_token: secret_token } + # end + # + # before do + # allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) + # end + # + # it "calls the Gitaly client with the project's repository" do + # expect(Gitlab::GitalyClient::Notifications). + # to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)). + # and_call_original + # expect_any_instance_of(Gitlab::GitalyClient::Notifications). + # to receive(:post_receive) + # + # post api("/internal/notify_post_receive"), valid_params + # + # expect(response).to have_http_status(200) + # end + # + # it "calls the Gitaly client with the wiki's repository if it's a wiki" do + # expect(Gitlab::GitalyClient::Notifications). + # to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)). + # and_call_original + # expect_any_instance_of(Gitlab::GitalyClient::Notifications). + # to receive(:post_receive) + # + # post api("/internal/notify_post_receive"), valid_wiki_params + # + # expect(response).to have_http_status(200) + # end + # + # it "returns 500 if the gitaly call fails" do + # expect_any_instance_of(Gitlab::GitalyClient::Notifications). + # to receive(:post_receive).and_raise(GRPC::Unavailable) + # + # post api("/internal/notify_post_receive"), valid_params + # + # expect(response).to have_http_status(500) + # end + # + # context 'with a gl_repository parameter' do + # let(:valid_params) do + # { gl_repository: "project-#{project.id}", secret_token: secret_token } + # end + # + # let(:valid_wiki_params) do + # { gl_repository: "wiki-#{project.id}", secret_token: secret_token } + # end + # + # it "calls the Gitaly client with the project's repository" do + # expect(Gitlab::GitalyClient::Notifications). + # to receive(:new).with(gitlab_git_repository_with(path: project.repository.path)). + # and_call_original + # expect_any_instance_of(Gitlab::GitalyClient::Notifications). + # to receive(:post_receive) + # + # post api("/internal/notify_post_receive"), valid_params + # + # expect(response).to have_http_status(200) + # end + # + # it "calls the Gitaly client with the wiki's repository if it's a wiki" do + # expect(Gitlab::GitalyClient::Notifications). + # to receive(:new).with(gitlab_git_repository_with(path: project.wiki.repository.path)). + # and_call_original + # expect_any_instance_of(Gitlab::GitalyClient::Notifications). + # to receive(:post_receive) + # + # post api("/internal/notify_post_receive"), valid_wiki_params + # + # expect(response).to have_http_status(200) + # end + # end + # end def project_with_repo_path(path) double().tap do |fake_project| |