summaryrefslogtreecommitdiff
path: root/qa/qa/factory/resource/label.rb
blob: 4080f15bf66246539f7c7cd855fa76642cc7c46b (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
36
37
38
39
require 'securerandom'

module QA
  module Factory
    module Resource
      class Label < Factory::Base
        attr_accessor :title,
                      :description,
                      :color

        product(:title) { |factory| factory.title }

        dependency Factory::Resource::Project, as: :project do |project|
          project.name = 'project-with-label'
        end

        def initialize
          @title = "qa-test-#{SecureRandom.hex(8)}"
          @description = 'This is a test label'
          @color = '#0033CC'
        end

        def fabricate!
          project.visit!

          Page::Project::Menu.act { go_to_labels }
          Page::Label::Index.act { go_to_new_label }

          Page::Label::New.perform do |page|
            page.fill_title(@title)
            page.fill_description(@description)
            page.fill_color(@color)
            page.create_label
          end
        end
      end
    end
  end
end