Commit b1a088ec authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'ml-qa-return-response-or-reraise-error' into 'master'

Re-raise exception if there is no response

Closes #34332

See merge request gitlab-org/gitlab!18856
parents a44873e1 64ef2c13
...@@ -4,9 +4,6 @@ module QA ...@@ -4,9 +4,6 @@ module QA
context 'Create' do context 'Create' do
describe 'Commit data' do describe 'Commit data' do
before(:context) do before(:context) do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
# Get the user's details to confirm they're included in the email patch # Get the user's details to confirm they're included in the email patch
@user = Resource::User.fabricate_via_api! do |user| @user = Resource::User.fabricate_via_api! do |user|
user.username = Runtime::User.username user.username = Runtime::User.username
...@@ -34,9 +31,12 @@ module QA ...@@ -34,9 +31,12 @@ module QA
end end
def view_commit def view_commit
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
@project.visit! @project.visit!
Page::Project::Show.perform do |page| # rubocop:disable QA/AmbiguousPageObjectName Page::Project::Show.perform do |show|
page.click_commit(@commit_message) show.click_commit(@commit_message)
end end
end end
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
payload: payload, payload: payload,
verify_ssl: false) verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e rescue RestClient::ExceptionWithResponse => e
e.response return_response_or_raise(e)
end end
def get(url, raw_response: false) def get(url, raw_response: false)
...@@ -24,7 +24,7 @@ module QA ...@@ -24,7 +24,7 @@ module QA
verify_ssl: false, verify_ssl: false,
raw_response: raw_response) raw_response: raw_response)
rescue RestClient::ExceptionWithResponse => e rescue RestClient::ExceptionWithResponse => e
e.response return_response_or_raise(e)
end end
def put(url, payload) def put(url, payload)
...@@ -34,7 +34,7 @@ module QA ...@@ -34,7 +34,7 @@ module QA
payload: payload, payload: payload,
verify_ssl: false) verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e rescue RestClient::ExceptionWithResponse => e
e.response return_response_or_raise(e)
end end
def delete(url) def delete(url)
...@@ -43,7 +43,7 @@ module QA ...@@ -43,7 +43,7 @@ module QA
url: url, url: url,
verify_ssl: false) verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e rescue RestClient::ExceptionWithResponse => e
e.response return_response_or_raise(e)
end end
def head(url) def head(url)
...@@ -52,12 +52,18 @@ module QA ...@@ -52,12 +52,18 @@ module QA
url: url, url: url,
verify_ssl: false) verify_ssl: false)
rescue RestClient::ExceptionWithResponse => e rescue RestClient::ExceptionWithResponse => e
e.response return_response_or_raise(e)
end end
def parse_body(response) def parse_body(response)
JSON.parse(response.body, symbolize_names: true) JSON.parse(response.body, symbolize_names: true)
end end
def return_response_or_raise(error)
raise error unless error.respond_to?(:response) && error.response
error.response
end
end end
end end
end end
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