1
0
Fork 0

Add factories for OrgUnitKind

This commit is contained in:
Alex Kotov 2019-10-02 17:05:32 +05:00
parent 50b3e28af1
commit c9ddfc996f
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 148 additions and 0 deletions

View File

@ -14,4 +14,54 @@ FactoryBot.define do
factory :some_children_org_unit_kind,
parent: :some_root_org_unit_kind,
traits: %i[with_parent]
factory :lpr_org_unit_kind, class: OrgUnitKind do
initialize_with do
OrgUnitKind.find_or_initialize_by codename: codename
end
codename { :lpr }
short_name { 'ЛПР' }
name { 'Либертарианская партия России' }
end
factory :reg_dept_org_unit_kind, parent: :lpr_org_unit_kind do
codename { :reg_dept }
short_name { 'РО' }
name { 'Региональное отделение' }
association :parent_kind, factory: :lpr_org_unit_kind
end
factory :fed_management_org_unit_kind, parent: :lpr_org_unit_kind do
codename { :fed_management }
short_name { 'ФК' }
name { 'Федеральный комитет' }
association :parent_kind, factory: :lpr_org_unit_kind
end
factory :fed_supervision_org_unit_kind, parent: :lpr_org_unit_kind do
codename { :fed_supervision }
short_name { 'ЦКРК' }
name { 'Центральная контрольно-ревизионная комиссия' }
association :parent_kind, factory: :lpr_org_unit_kind
end
factory :reg_management_org_unit_kind, parent: :lpr_org_unit_kind do
codename { :reg_management }
short_name { 'РК РО' }
name { 'Руководящий комитет регионального отделения' }
association :parent_kind, factory: :reg_dept_org_unit_kind
end
factory :reg_supervision_org_unit_kind, parent: :lpr_org_unit_kind do
codename { :reg_supervision }
short_name { 'РКРК' }
name { 'Региональная контрольно-ревизионная комиссия' }
association :parent_kind, factory: :reg_dept_org_unit_kind
end
end

View File

@ -17,4 +17,102 @@ FactoryBot.define do
factory :some_children_org_unit,
parent: :some_root_org_unit,
traits: %i[with_parent]
factory :lpr_org_unit, class: OrgUnit do
initialize_with do
OrgUnit.find_or_initialize_by short_name: short_name
end
short_name { 'ЛПР' }
name { 'Либертарианская партия России' }
association :kind, factory: :lpr_org_unit_kind
end
factory :moscow_reg_dept_org_unit, parent: :lpr_org_unit do
short_name { 'РО ЛПР в Москве' }
name { 'Региональное отделение Либертарианской партии России в Москве' }
association :kind, factory: :reg_dept_org_unit_kind
association :parent_unit, factory: :lpr_org_unit
end
factory :perm_reg_dept_org_unit, parent: :lpr_org_unit do
short_name { 'РО ЛПР в Пермском крае' }
name do
'Региональное отделение Либертарианской партии России в Пермском крае'
end
association :kind, factory: :reg_dept_org_unit_kind
association :parent_unit, factory: :lpr_org_unit
end
factory :fed_management_org_unit, parent: :lpr_org_unit do
short_name { 'ФК ЛПР' }
name { 'Федеральный комитет Либертарианской партии России' }
association :kind, factory: :fed_management_org_unit_kind
association :parent_unit, factory: :lpr_org_unit
end
factory :fed_supervision_org_unit, parent: :lpr_org_unit do
short_name { 'ЦКРК ЛПР' }
name do
'Центральная контрольно-ревизионная комиссия ' \
'Либертарианской партии России'
end
association :kind, factory: :fed_supervision_org_unit_kind
association :parent_unit, factory: :lpr_org_unit
end
factory :moscow_reg_management_org_unit, parent: :lpr_org_unit do
short_name { 'РК РО ЛПР в Москве' }
name do
'Руководящий комитет регионального отделения ' \
'Либертарианской партии России в Москве'
end
association :kind, factory: :reg_management_org_unit_kind
association :parent_unit, factory: :moscow_reg_dept_org_unit
end
factory :moscow_reg_supervision_org_unit, parent: :lpr_org_unit do
short_name { 'РКРК ЛПР в Москве' }
name do
'Региональная контрольно-ревизионная комиссия' \
'Либертарианской партии России в Москве'
end
association :kind, factory: :reg_supervision_org_unit_kind
association :parent_unit, factory: :moscow_reg_dept_org_unit
end
factory :perm_reg_management_org_unit, parent: :lpr_org_unit do
short_name { 'РК РО ЛПР в Пермском крае' }
name do
'Руководящий комитет регионального отделения ' \
'Либертарианской партии России в Пермском крае'
end
association :kind, factory: :reg_management_org_unit_kind
association :parent_unit, factory: :perm_reg_dept_org_unit
end
factory :perm_reg_supervision_org_unit, parent: :lpr_org_unit do
short_name { 'РКРК ЛПР в Пермском крае' }
name do
'Региональная контрольно-ревизионная комиссия' \
'Либертарианской партии России в Пермском крае'
end
association :kind, factory: :reg_supervision_org_unit_kind
association :parent_unit, factory: :perm_reg_dept_org_unit
end
end