diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-12 23:17:05 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-12 23:17:05 -0700 |
commit | ec4109d413f6161b43ad4cc1a6251af30d3bcf03 (patch) | |
tree | c2db2b3ae4335752d014d43516526fca48187cf0 /lib/bitbucket_server | |
parent | 15220291ae1752b9e36ad0b2320180614ec37c59 (diff) | |
download | gitlab-ce-ec4109d413f6161b43ad4cc1a6251af30d3bcf03.tar.gz |
Make Connection#post consistent with Connection#get and add specs
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/connection.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/bitbucket_server/connection.rb b/lib/bitbucket_server/connection.rb index 0e7817fc82e..853d09b776a 100644 --- a/lib/bitbucket_server/connection.rb +++ b/lib/bitbucket_server/connection.rb @@ -33,22 +33,22 @@ module BitbucketServer check_errors!(response) - response + response.parsed_response end private def check_errors!(response) - if response.code != 200 - error = - if response.parsed_response && response.parsed_response.is_a?(Hash) - sanitize(response.parsed_response.dig('errors', 0, 'message')) - end - - message = "Error #{response.code}" - message += ": #{error}" if error - raise ConnectionError, message - end + return if response.code == 200 + + details = + if response.parsed_response && response.parsed_response.is_a?(Hash) + sanitize(response.parsed_response.dig('errors', 0, 'message')) + end + + message = "Error #{response.code}" + message += ": #{details}" if details + raise ConnectionError, message end def auth |