Commit a0856cf7 authored by Stan Hu's avatar Stan Hu

Fix BitbucketServer::Client failing with Webmock 3.5.1

Webmock 3.1.0 changed the behavior to return `nil` for the body if an
HTTP 204 No Content response were received
(https://github.com/bblimke/webmock/commit/b837e642782501a6904d0cb1aad391dd6f49ada3).

Update the Bitbucket Server connection to ignore these No Content
response codes.
parent a6b7c4ee
......@@ -77,6 +77,7 @@ module BitbucketServer
private
def check_errors!(response)
return if ActionDispatch::Response::NO_CONTENT_CODES.include?(response.code)
raise ConnectionError, "Response is not valid JSON" unless response.parsed_response.is_a?(Hash)
return if response.code >= 200 && response.code < 300
......
......@@ -64,7 +64,7 @@ describe BitbucketServer::Client do
let(:url) { "#{base_uri}rest/api/1.0/projects/SOME-PROJECT/repos/my-repo/branches" }
it 'requests Bitbucket to create a branch' do
stub_request(:post, url).to_return(status: 204, headers: headers, body: '{}')
stub_request(:post, url).to_return(status: 204, headers: headers, body: nil)
subject.create_branch(project, repo_slug, branch, sha)
......@@ -78,7 +78,7 @@ describe BitbucketServer::Client do
let(:url) { "#{base_uri}rest/branch-utils/1.0/projects/SOME-PROJECT/repos/my-repo/branches" }
it 'requests Bitbucket to create a branch' do
stub_request(:delete, url).to_return(status: 204, headers: headers, body: '{}')
stub_request(:delete, url).to_return(status: 204, headers: headers, body: nil)
subject.delete_branch(project, repo_slug, branch, sha)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment