summaryrefslogtreecommitdiff
path: root/spec/factories/events.rb
blob: ed275243ac96a287056fb43e0e471c1b42935474 (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
FactoryBot.define do
  factory :event do
    project
    author factory: :user
    action Event::JOINED

    trait(:created)   { action Event::CREATED }
    trait(:updated)   { action Event::UPDATED }
    trait(:closed)    { action Event::CLOSED }
    trait(:reopened)  { action Event::REOPENED }
    trait(:pushed)    { action Event::PUSHED }
    trait(:commented) { action Event::COMMENTED }
    trait(:merged)    { action Event::MERGED }
    trait(:joined)    { action Event::JOINED }
    trait(:left)      { action Event::LEFT }
    trait(:destroyed) { action Event::DESTROYED }
    trait(:expired)   { action Event::EXPIRED }

    factory :closed_issue_event do
      action { Event::CLOSED }
      target factory: :closed_issue
    end
  end

  factory :push_event, class: PushEvent do
    project factory: :project_empty_repo
    author factory: :user
    action Event::PUSHED
  end

  factory :push_event_payload do
    event
    commit_count 1
    action :pushed
    ref_type :branch
    ref 'master'
    commit_to '3cdce97ed87c91368561584e7358f4d46e3e173c'
  end
end