diff options
author | Stan Hu <stanhu@gmail.com> | 2016-03-13 00:05:23 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-03-13 00:05:23 +0300 |
commit | 74d7de81960e6d7037c5ae7d4ecd953ac6ea5deb (patch) | |
tree | f1fb527c31109bf1370c3f1e560e2ded7d87920c /spec/lib/gitlab/middleware | |
parent | 30ab290b2829b84f4abb9d18f9b907bb9212f445 (diff) |
Revert "Revert "Merge branch 'support-go-subpackages' into 'master'
""
This reverts commit 5a586f364c5d2b866d6a074eff7996f05585b7d5
Diffstat (limited to 'spec/lib/gitlab/middleware')
-rw-r--r-- | spec/lib/gitlab/middleware/go_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb new file mode 100644 index 00000000000..117a15264da --- /dev/null +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe Gitlab::Middleware::Go, lib: true do + let(:app) { double(:app) } + let(:middleware) { described_class.new(app) } + + describe '#call' do + describe 'when go-get=0' do + it 'skips go-import generation' do + env = { 'rack.input' => '', + 'QUERY_STRING' => 'go-get=0' } + expect(app).to receive(:call).with(env).and_return('no-go') + middleware.call(env) + end + end + + describe 'when go-get=1' do + it 'returns a document' do + env = { 'rack.input' => '', + 'QUERY_STRING' => 'go-get=1', + 'PATH_INFO' => '/group/project/path' } + resp = middleware.call(env) + expect(resp[0]).to eq(200) + expect(resp[1]['Content-Type']).to eq('text/html') + expected_body = "<!DOCTYPE html><html><head><meta content='localhost/group/project git http://localhost/group/project.git' name='go-import'></head></html>\n" + expect(resp[2].body).to eq([expected_body]) + end + end + end +end |