summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 15:07:52 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 15:07:52 +0000
commit27d91a629918e417a9e87825e838209b9ace79c1 (patch)
treee066c3fc84e3011641e662252810cb2c240edb90 /qa
parent5e11c9b77cb1b2b77ee29359047b55807afe255d (diff)
downloadgitlab-ce-27d91a629918e417a9e87825e838209b9ace79c1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/search/results.rb21
-rw-r--r--qa/qa/resource/api_fabricator.rb16
-rw-r--r--qa/qa/runtime/api/client.rb17
3 files changed, 48 insertions, 6 deletions
diff --git a/qa/qa/page/search/results.rb b/qa/qa/page/search/results.rb
index b9b18abf660..2f99d8da784 100644
--- a/qa/qa/page/search/results.rb
+++ b/qa/qa/page/search/results.rb
@@ -5,6 +5,7 @@ module QA::Page
class Results < QA::Page::Base
view 'app/views/search/_category.html.haml' do
element :code_tab
+ element :projects_tab
end
view 'app/views/search/results/_blob_data.html.haml' do
@@ -13,21 +14,33 @@ module QA::Page
element :file_text_content
end
+ view 'app/views/shared/projects/_project.html.haml' do
+ element :project
+ end
+
def switch_to_code
click_element(:code_tab)
end
+ def switch_to_projects
+ click_element(:projects_tab)
+ end
+
def has_file_in_project?(file_name, project_name)
- has_element? :result_item_content, text: "#{project_name}: #{file_name}"
+ has_element?(:result_item_content, text: "#{project_name}: #{file_name}")
end
def has_file_with_content?(file_name, file_text)
- within_element_by_index :result_item_content, 0 do
- false unless has_element? :file_title_content, text: file_name
+ within_element_by_index(:result_item_content, 0) do
+ false unless has_element?(:file_title_content, text: file_name)
- has_element? :file_text_content, text: file_text
+ has_element?(:file_text_content, text: file_text)
end
end
+
+ def has_project?(project_name)
+ has_element?(:project, project_name: project_name)
+ end
end
end
end
diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb
index e4f708dc251..3862bd68c40 100644
--- a/qa/qa/resource/api_fabricator.rb
+++ b/qa/qa/resource/api_fabricator.rb
@@ -19,8 +19,8 @@ module QA
def api_support?
respond_to?(:api_get_path) &&
- respond_to?(:api_post_path) &&
- respond_to?(:api_post_body)
+ (respond_to?(:api_post_path) && respond_to?(:api_post_body)) ||
+ (respond_to?(:api_put_path) && respond_to?(:api_put_body))
end
def fabricate_via_api!
@@ -84,6 +84,18 @@ module QA
process_api_response(parse_body(response))
end
+ def api_put
+ response = put(
+ Runtime::API::Request.new(api_client, api_put_path).url,
+ api_put_body)
+
+ unless response.code == HTTP_STATUS_OK
+ raise ResourceFabricationFailedError, "Updating #{self.class.name} using the API failed (#{response.code}) with `#{response}`."
+ end
+
+ process_api_response(parse_body(response))
+ end
+
def api_delete
url = Runtime::API::Request.new(api_client, api_delete_path).url
response = delete(url)
diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb
index 4f9fb586ee3..b9a3c9184aa 100644
--- a/qa/qa/runtime/api/client.rb
+++ b/qa/qa/runtime/api/client.rb
@@ -25,6 +25,23 @@ module QA
end
end
+ def self.as_admin
+ if Runtime::Env.admin_personal_access_token
+ Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.admin_personal_access_token)
+ else
+ user = Resource::User.fabricate_via_api! do |user|
+ user.username = Runtime::User.admin_username
+ user.password = Runtime::User.admin_password
+ end
+
+ unless user.admin?
+ raise AuthorizationError, "User '#{user.username}' is not an administrator."
+ end
+
+ Runtime::API::Client.new(:gitlab, user: user)
+ end
+ end
+
private
def enable_ip_limits