summaryrefslogtreecommitdiff
path: root/qa/qa/factory/resource/file.rb
blob: 1148876c2d336b0df59e31151f2663da8a5283e7 (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
# frozen_string_literal: true

module QA
  module Factory
    module Resource
      class File < Factory::Base
        attr_accessor :name,
                      :content,
                      :commit_message

        attribute :project do
          Factory::Resource::Project.fabricate! do |resource|
            resource.name = 'project-with-new-file'
          end
        end

        def initialize
          @name = 'QA Test - File name'
          @content = 'QA Test - File content'
          @commit_message = 'QA Test - Commit message'
        end

        def fabricate!
          project.visit!

          Page::Project::Show.perform(&:create_new_file!)

          Page::File::Form.perform do |page|
            page.add_name(@name)
            page.add_content(@content)
            page.add_commit_message(@commit_message)
            page.commit_changes
          end
        end
      end
    end
  end
end