summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket_server
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-12 23:17:05 -0700
committerStan Hu <stanhu@gmail.com>2018-07-12 23:17:05 -0700
commitec4109d413f6161b43ad4cc1a6251af30d3bcf03 (patch)
treec2db2b3ae4335752d014d43516526fca48187cf0 /spec/lib/bitbucket_server
parent15220291ae1752b9e36ad0b2320180614ec37c59 (diff)
downloadgitlab-ce-ec4109d413f6161b43ad4cc1a6251af30d3bcf03.tar.gz
Make Connection#post consistent with Connection#get and add specs
Diffstat (limited to 'spec/lib/bitbucket_server')
-rw-r--r--spec/lib/bitbucket_server/connection_spec.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/lib/bitbucket_server/connection_spec.rb b/spec/lib/bitbucket_server/connection_spec.rb
index 911f6eea8bf..45affbcf4e4 100644
--- a/spec/lib/bitbucket_server/connection_spec.rb
+++ b/spec/lib/bitbucket_server/connection_spec.rb
@@ -4,12 +4,11 @@ describe BitbucketServer::Connection do
let(:options) { { base_uri: 'https://test:7990', user: 'bitbucket', password: 'mypassword' } }
let(:payload) { { 'test' => 1 } }
let(:headers) { { "Content-Type" => "application/json" } }
+ let(:url) { 'https://test:7990/rest/api/1.0/test?something=1' }
subject { described_class.new(options) }
describe '#get' do
- let(:url) { 'https://test:7990/rest/api/1.0/test?something=1' }
-
it 'returns JSON body' do
WebMock.stub_request(:get, url).to_return(body: payload.to_json, status: 200, headers: headers)
@@ -24,5 +23,16 @@ describe BitbucketServer::Connection do
end
describe '#post' do
+ it 'returns JSON body' do
+ WebMock.stub_request(:post, url).to_return(body: payload.to_json, status: 200, headers: headers)
+
+ expect(subject.post(url, payload)).to eq(payload)
+ end
+
+ it 'throws an exception if the response is not 200' do
+ WebMock.stub_request(:post, url).to_return(body: payload.to_json, status: 500, headers: headers)
+
+ expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
+ end
end
end