2019-04-27 10:24:04 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
2019-10-01 21:31:12 -04:00
|
|
|
factory :some_root_relationship, class: Relationship do
|
|
|
|
association :org_unit, factory: :some_root_org_unit
|
2019-09-28 17:21:34 -04:00
|
|
|
association :status, factory: :some_relation_status
|
2019-04-27 10:24:04 -04:00
|
|
|
association :person, factory: :initial_person
|
2019-04-28 08:48:51 -04:00
|
|
|
|
2019-07-20 02:22:47 -04:00
|
|
|
sequence :from_date do |n|
|
2019-06-04 21:37:55 -04:00
|
|
|
Date.new rand((10 * n)...(11 * n)), rand(1..12), rand(1..28)
|
|
|
|
end
|
2019-10-01 21:31:12 -04:00
|
|
|
|
|
|
|
trait :with_parent do
|
|
|
|
association :org_unit, factory: :some_children_org_unit
|
|
|
|
|
|
|
|
parent_rel do
|
2019-10-02 14:13:02 -04:00
|
|
|
create :some_root_relationship,
|
|
|
|
person: person,
|
|
|
|
org_unit: org_unit&.parent_unit
|
2019-10-01 21:31:12 -04:00
|
|
|
end
|
|
|
|
end
|
2019-04-28 08:48:51 -04:00
|
|
|
end
|
|
|
|
|
2019-10-01 21:31:12 -04:00
|
|
|
factory :some_children_relationship,
|
|
|
|
parent: :some_root_relationship,
|
|
|
|
traits: %i[with_parent]
|
|
|
|
|
2019-10-02 14:13:02 -04:00
|
|
|
factory :excluded_relationship, parent: :some_root_relationship do
|
2019-10-02 09:43:55 -04:00
|
|
|
association :org_unit, factory: :lpr_org_unit
|
|
|
|
association :status, factory: :excluded_member_relation_status
|
|
|
|
parent_rel { nil }
|
|
|
|
end
|
2019-10-01 21:31:12 -04:00
|
|
|
|
2019-10-02 14:13:02 -04:00
|
|
|
factory :included_relationship, parent: :some_root_relationship do
|
2019-10-02 09:43:55 -04:00
|
|
|
association :org_unit, factory: :lpr_org_unit
|
|
|
|
association :status, factory: :included_relation_status
|
|
|
|
parent_rel { nil }
|
|
|
|
end
|
2019-07-20 05:12:58 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :supporter_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :moscow_reg_dept_org_unit
|
|
|
|
association :status, factory: :supporter_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :included_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-20 05:12:58 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :member_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :moscow_reg_dept_org_unit
|
|
|
|
association :status, factory: :active_member_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :included_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-25 22:06:01 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :federal_manager_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :fed_management_org_unit
|
|
|
|
association :status, factory: :fed_manager_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :included_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-25 22:09:52 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :federal_supervisor_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :fed_supervision_org_unit
|
|
|
|
association :status, factory: :fed_supervisor_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :included_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-20 05:12:58 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :regional_manager_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :moscow_reg_management_org_unit
|
|
|
|
association :status, factory: :reg_manager_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :member_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-25 23:22:12 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :regional_supervisor_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :moscow_reg_supervision_org_unit
|
|
|
|
association :status, factory: :reg_supervisor_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :member_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-07-25 23:40:06 -04:00
|
|
|
|
2019-10-02 09:43:55 -04:00
|
|
|
factory :federal_secretary_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :fed_management_org_unit
|
|
|
|
association :status, factory: :fed_secretary_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :included_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :regional_secretary_relationship, parent: :excluded_relationship do
|
|
|
|
association :org_unit, factory: :moscow_reg_management_org_unit
|
|
|
|
association :status, factory: :reg_secretary_relation_status
|
2019-10-02 14:13:02 -04:00
|
|
|
parent_rel { create :member_relationship, person: person }
|
2019-10-02 09:43:55 -04:00
|
|
|
end
|
2019-04-27 10:24:04 -04:00
|
|
|
end
|