diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-11-02 17:32:28 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-11-05 22:20:57 +0800 |
commit | 4d0fd75cd5ceda72692a229d27ab6891fa8082e0 (patch) | |
tree | 7448b28ca974c9480e1e96b0d90c1322eeb9f0c7 /qa/qa/resource/group.rb | |
parent | c12a4a9ac7c04a215adf6062fec7bf31231c7d4a (diff) | |
download | gitlab-ce-4d0fd75cd5ceda72692a229d27ab6891fa8082e0.tar.gz |
Rename QA::Factory to QA::Resource53224-rename-to-resource-base-qa
* Factory::Base -> Resource::Base, and therefore:
* Factory::Resource::Project -> Resource::Project
Diffstat (limited to 'qa/qa/resource/group.rb')
-rw-r--r-- | qa/qa/resource/group.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb new file mode 100644 index 00000000000..dce15e4f10b --- /dev/null +++ b/qa/qa/resource/group.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module QA + module Resource + class Group < Base + attr_accessor :path, :description + + attribute :sandbox do + Sandbox.fabricate! + end + + attribute :id + + def initialize + @path = Runtime::Namespace.name + @description = "QA test run at #{Runtime::Namespace.time}" + end + + def fabricate! + sandbox.visit! + + Page::Group::Show.perform do |group_show| + if group_show.has_subgroup?(path) + group_show.go_to_subgroup(path) + else + group_show.go_to_new_subgroup + + Page::Group::New.perform do |group_new| + group_new.set_path(path) + group_new.set_description(description) + group_new.set_visibility('Public') + group_new.create + end + + # Ensure that the group was actually created + group_show.wait(time: 1) do + group_show.has_text?(path) && + group_show.has_new_project_or_subgroup_dropdown? + end + end + end + end + + def fabricate_via_api! + resource_web_url(api_get) + rescue ResourceNotFoundError + super + end + + def api_get_path + "/groups/#{CGI.escape("#{sandbox.path}/#{path}")}" + end + + def api_post_path + '/groups' + end + + def api_post_body + { + parent_id: sandbox.id, + path: path, + name: path, + visibility: 'public' + } + end + end + end +end |