Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_customer_relations_contacts.rb « customer_relations « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8ea1a521a332a64aa9197750daea764a5b9a3118 (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
# frozen_string_literal: true

FactoryBot.define do
  factory :issue_customer_relations_contact, class: 'CustomerRelations::IssueContact' do
    issue { association(:issue, project: project) }
    contact { association(:contact, group: group) }

    transient do
      group { association(:group) }
      project { association(:project, group: group) }
    end

    trait :for_contact do
      issue { association(:issue, project: project) }
      contact { raise ArgumentError, '`contact` is manadatory' }

      transient do
        project { association(:project, group: contact.group) }
      end
    end

    trait :for_issue do
      issue { raise ArgumentError, '`issue` is manadatory' }
      contact { association(:contact, group: issue.project.root_ancestor) }
    end
  end
end