summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanad Liaquat <sliaquat@gitlab.com>2018-11-19 18:01:38 +0500
committerSanad Liaquat <sliaquat@gitlab.com>2018-11-23 15:44:56 +0500
commit815235ffa0e8818edbb31fead656387b64e4792f (patch)
treea7171fca793fb9567bccd9e53c45d2e0413327a0
parenta22f442d037c9b77152cc26bb740a9ffd004c6b6 (diff)
downloadgitlab-ce-qa-193-ldap-group-sync-ce.tar.gz
-rw-r--r--qa/qa.rb1
-rw-r--r--qa/qa/resource/api_fabricator.rb24
-rw-r--r--qa/qa/support/api.rb28
3 files changed, 30 insertions, 23 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index c0d5244dbfa..aa0b78b37e8 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -329,6 +329,7 @@ module QA
module Page
autoload :Logging, 'qa/support/page/logging'
end
+ autoload :Api, 'qa/support/api'
end
end
diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb
index 397dfb16aa4..98eebac0880 100644
--- a/qa/qa/resource/api_fabricator.rb
+++ b/qa/qa/resource/api_fabricator.rb
@@ -41,6 +41,7 @@ module QA
private
+ include Support::Api
attr_writer :api_resource, :api_response
def resource_web_url(resource)
@@ -82,10 +83,6 @@ module QA
end
end
- def parse_body(response)
- JSON.parse(response.body, symbolize_names: true)
- end
-
def process_api_response(parsed_response)
self.api_response = parsed_response
self.api_resource = transform_api_resource(parsed_response.deep_dup)
@@ -94,25 +91,6 @@ module QA
def transform_api_resource(api_resource)
api_resource
end
-
- def post(url, payload)
- RestClient::Request.execute(
- method: :post,
- url: url,
- payload: payload,
- verify_ssl: false)
- rescue RestClient::ExceptionWithResponse => e
- e.response
- end
-
- def get(url)
- RestClient::Request.execute(
- method: :get,
- url: url,
- verify_ssl: false)
- rescue RestClient::ExceptionWithResponse => e
- e.response
- end
end
end
end
diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb
new file mode 100644
index 00000000000..1107d43161e
--- /dev/null
+++ b/qa/qa/support/api.rb
@@ -0,0 +1,28 @@
+module QA
+ module Support
+ module Api
+ def post(url, payload)
+ RestClient::Request.execute(
+ method: :post,
+ url: url,
+ payload: payload,
+ verify_ssl: false)
+ rescue RestClient::ExceptionWithResponse => e
+ e.response
+ end
+
+ def get(url)
+ RestClient::Request.execute(
+ method: :get,
+ url: url,
+ verify_ssl: false)
+ rescue RestClient::ExceptionWithResponse => e
+ e.response
+ end
+
+ def parse_body(response)
+ JSON.parse(response.body, symbolize_names: true)
+ end
+ end
+ end
+end