summaryrefslogtreecommitdiff
path: root/qa/qa/factory/resource/group.rb
blob: 9f13e26f35ce69f00fd46ad61a8f7501df21bbfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module QA
  module Factory
    module Resource
      class Group < Factory::Base
        attr_writer :path, :description

        dependency Factory::Resource::Sandbox, as: :sandbox

        def initialize
          @path = Runtime::Namespace.name
          @description = "QA test run at #{Runtime::Namespace.time}"
        end

        def fabricate!
          sandbox.visit!

          Page::Group::Show.perform do |page|
            if page.has_subgroup?(@path)
              page.go_to_subgroup(@path)
            else
              page.go_to_new_subgroup

              Page::Group::New.perform do |group|
                group.set_path(@path)
                group.set_description(@description)
                group.set_visibility('Private')
                group.create
              end
            end
          end
        end
      end
    end
  end
end