summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2018-03-28 16:24:22 +0200
committerJacob Vosmaer <jacob@gitlab.com>2018-03-28 16:24:22 +0200
commit74900c6b4bfed02ad19af614ab337e0fa24415af (patch)
tree23b112604c00402daa68c87a9a36e13bb7c51737
parent84eabf7bc67687071467e65251917387e795f8d4 (diff)
downloadgitlab-ce-workhorse-still-needs-repopath.tar.gz
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb115
1 files changed, 62 insertions, 53 deletions
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index 5e8d728b839..3381603cb75 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -275,22 +275,15 @@ describe Gitlab::Workhorse do
describe '.git_http_ok' do
let(:user) { create(:user) }
+ let(:repo_path) { 'ignored but not allowed to be empty in gitlab-workhorse' }
let(:action) { 'info_refs' }
let(:params) do
{
GL_ID: "user-#{user.id}",
GL_USERNAME: user.username,
GL_REPOSITORY: "project-#{project.id}",
- ShowAllRefs: false,
- RepoPath: 'ignored but not allowed to be empty in gitlab-workhorse'
- }
- end
- let(:gitaly_params) do
- {
- GitalyServer: {
- address: Gitlab::GitalyClient.address('default'),
- token: Gitlab::GitalyClient.token('default')
- }
+ RepoPath: repo_path,
+ ShowAllRefs: false
}
end
@@ -298,70 +291,86 @@ describe Gitlab::Workhorse do
it { expect(subject).to include(params) }
- it 'includes a Repository param' do
- repo_param = {
- storage_name: 'default',
- relative_path: project.disk_path + '.git',
- gl_repository: "project-#{project.id}"
- }
+ context 'when is_wiki' do
+ let(:params) do
+ {
+ GL_ID: "user-#{user.id}",
+ GL_USERNAME: user.username,
+ GL_REPOSITORY: "wiki-#{project.id}",
+ RepoPath: repo_path,
+ ShowAllRefs: false
+ }
+ end
- expect(subject[:Repository]).to include(repo_param)
- end
+ subject { described_class.git_http_ok(repository, true, user, action) }
- context "when git_upload_pack action is passed" do
- let(:action) { 'git_upload_pack' }
- let(:feature_flag) { :post_upload_pack }
+ it { expect(subject).to include(params) }
+ end
- it 'includes Gitaly params in the returned value' do
- allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(feature_flag).and_return(true)
+ context 'when Gitaly is enabled' do
+ let(:gitaly_params) do
+ {
+ GitalyServer: {
+ address: Gitlab::GitalyClient.address('default'),
+ token: Gitlab::GitalyClient.token('default')
+ }
+ }
+ end
- expect(subject).to include(gitaly_params)
+ before do
+ allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
end
- context 'show_all_refs enabled' do
- subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
+ it 'includes a Repository param' do
+ repo_param = {
+ storage_name: 'default',
+ relative_path: project.disk_path + '.git',
+ gl_repository: "project-#{project.id}"
+ }
- it { is_expected.to include(ShowAllRefs: true) }
+ expect(subject[:Repository]).to include(repo_param)
end
- end
- context "when git_receive_pack action is passed" do
- let(:action) { 'git_receive_pack' }
+ context "when git_upload_pack action is passed" do
+ let(:action) { 'git_upload_pack' }
+ let(:feature_flag) { :post_upload_pack }
- it { expect(subject).to include(gitaly_params) }
- end
+ it 'includes Gitaly params in the returned value' do
+ allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(feature_flag).and_return(true)
+
+ expect(subject).to include(gitaly_params)
+ end
- context "when info_refs action is passed" do
- let(:action) { 'info_refs' }
+ context 'show_all_refs enabled' do
+ subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
- it { expect(subject).to include(gitaly_params) }
+ it { is_expected.to include(ShowAllRefs: true) }
+ end
+ end
- context 'show_all_refs enabled' do
- subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
+ context "when git_receive_pack action is passed" do
+ let(:action) { 'git_receive_pack' }
- it { is_expected.to include(ShowAllRefs: true) }
+ it { expect(subject).to include(gitaly_params) }
end
- end
- context 'when action passed is not supported by Gitaly' do
- let(:action) { 'download' }
+ context "when info_refs action is passed" do
+ let(:action) { 'info_refs' }
- it { expect { subject }.to raise_exception('Unsupported action: download') }
- end
+ it { expect(subject).to include(gitaly_params) }
- context 'when is_wiki' do
- let(:params) do
- {
- GL_ID: "user-#{user.id}",
- GL_USERNAME: user.username,
- GL_REPOSITORY: "wiki-#{project.id}",
- ShowAllRefs: false
- }
+ context 'show_all_refs enabled' do
+ subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
+
+ it { is_expected.to include(ShowAllRefs: true) }
+ end
end
- subject { described_class.git_http_ok(repository, true, user, action) }
+ context 'when action passed is not supported by Gitaly' do
+ let(:action) { 'download' }
- it { expect(subject).to include(params) }
+ it { expect { subject }.to raise_exception('Unsupported action: download') }
+ end
end
end