diff options
Diffstat (limited to 'qa/qa/resource/project.rb')
-rw-r--r-- | qa/qa/resource/project.rb | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index cb047f81d02..78e2ba8a248 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -7,11 +7,11 @@ module QA class Project < Base include Events::Project include Members + include Visibility attr_accessor :repository_storage # requires admin access attr_writer :initialize_with_readme attr_writer :auto_devops_enabled - attr_writer :visibility attribute :id attribute :name @@ -19,6 +19,8 @@ module QA attribute :description attribute :standalone attribute :runners_token + attribute :visibility + attribute :template_name attribute :group do Group.fabricate! @@ -50,7 +52,8 @@ module QA @description = 'My awesome project' @initialize_with_readme = false @auto_devops_enabled = false - @visibility = 'public' + @visibility = :public + @template_name = nil end def name=(raw_name) @@ -63,6 +66,13 @@ module QA Page::Group::Show.perform(&:go_to_new_project) end + if @template_name + Page::Project::New.perform do |new_page| + new_page.click_create_from_template_tab + new_page.use_template_for_project(@template_name) + end + end + Page::Project::New.perform do |new_page| new_page.choose_test_namespace new_page.choose_name(@name) @@ -83,6 +93,10 @@ module QA "/projects/#{CGI.escape(path_with_namespace)}" end + def api_visibility_path + "/projects/#{id}" + end + def api_get_archive_path(type = 'tar.gz') "#{api_get_path}/repository/archive.#{type}" end @@ -95,6 +109,10 @@ module QA "#{api_get_path}/runners" end + def api_pipelines_path + "#{api_get_path}/pipelines" + end + def api_put_path "/projects/#{id}" end @@ -118,6 +136,7 @@ module QA end post_body[:repository_storage] = repository_storage if repository_storage + post_body[:template_name] = @template_name if @template_name post_body end @@ -152,10 +171,19 @@ module QA end def runners(tag_list: nil) - response = get Runtime::API::Request.new(api_client, "#{api_runners_path}?tag_list=#{tag_list.compact.join(',')}").url + response = if tag_list + get Runtime::API::Request.new(api_client, "#{api_runners_path}?tag_list=#{tag_list.compact.join(',')}").url + else + get Runtime::API::Request.new(api_client, "#{api_runners_path}").url + end + parse_body(response) end + def pipelines + parse_body(get(Runtime::API::Request.new(api_client, api_pipelines_path).url)) + end + def share_with_group(invitee, access_level = Resource::Members::AccessLevel::DEVELOPER) post Runtime::API::Request.new(api_client, "/projects/#{id}/share").url, { group_id: invitee.id, group_access: access_level } end |