Add role "federal_supervisor"
This commit is contained in:
parent
9702540502
commit
8160514840
6 changed files with 37 additions and 5 deletions
|
@ -3,7 +3,12 @@
|
|||
class Relationship < ApplicationRecord
|
||||
pg_enum :status, %i[supporter excluded member]
|
||||
|
||||
pg_enum :role, %i[federal_manager regional_manager regional_supervisor]
|
||||
pg_enum :role, %i[
|
||||
federal_manager
|
||||
federal_supervisor
|
||||
regional_manager
|
||||
regional_supervisor
|
||||
]
|
||||
|
||||
################
|
||||
# Associations #
|
||||
|
@ -19,6 +24,8 @@ class Relationship < ApplicationRecord
|
|||
|
||||
scope :federal_managers, -> { where(role: :federal_manager) }
|
||||
|
||||
scope :federal_supervisors, -> { where(role: :federal_supervisor) }
|
||||
|
||||
###############
|
||||
# Validations #
|
||||
###############
|
||||
|
|
|
@ -9,6 +9,7 @@ ru:
|
|||
member: Член партии
|
||||
relationship_role:
|
||||
federal_manager: Член федерального комитета
|
||||
federal_supervisor: Член центральной контрольно-ревизионной комиссии
|
||||
regional_manager: Член руководящего комитета регионального отделения
|
||||
regional_supervisor: >-
|
||||
Член контрольно-ревизионной комиссии регионального отделения
|
||||
|
|
|
@ -17,6 +17,7 @@ private
|
|||
|
||||
enum :relationship_role, %i[
|
||||
federal_manager
|
||||
federal_supervisor
|
||||
regional_manager
|
||||
regional_supervisor
|
||||
]
|
||||
|
|
|
@ -44,6 +44,7 @@ CREATE TYPE public.person_comment_origin AS ENUM (
|
|||
|
||||
CREATE TYPE public.relationship_role AS ENUM (
|
||||
'federal_manager',
|
||||
'federal_supervisor',
|
||||
'regional_manager',
|
||||
'regional_supervisor'
|
||||
);
|
||||
|
|
|
@ -29,6 +29,10 @@ FactoryBot.define do
|
|||
role { :federal_manager }
|
||||
end
|
||||
|
||||
factory :federal_supervisor_relationship, parent: :member_relationship do
|
||||
role { :federal_supervisor }
|
||||
end
|
||||
|
||||
factory :regional_manager_relationship, parent: :member_relationship do
|
||||
role { :regional_manager }
|
||||
end
|
||||
|
|
|
@ -72,13 +72,31 @@ RSpec.describe Relationship do
|
|||
let!(:relationship3) { create :excluded_supporter_relationship }
|
||||
let!(:relationship3) { create :excluded_member_relationship }
|
||||
let!(:relationship4) { create :federal_manager_relationship }
|
||||
let!(:relationship5) { create :regional_manager_relationship }
|
||||
let!(:relationship6) { create :regional_supervisor_relationship }
|
||||
let!(:relationship7) { create :federal_manager_relationship }
|
||||
let!(:relationship5) { create :federal_supervisor_relationship }
|
||||
let!(:relationship6) { create :regional_manager_relationship }
|
||||
let!(:relationship7) { create :regional_supervisor_relationship }
|
||||
let!(:relationship8) { create :federal_manager_relationship }
|
||||
|
||||
specify do
|
||||
expect(described_class.federal_managers).to \
|
||||
eq [relationship4, relationship7]
|
||||
eq [relationship4, relationship8]
|
||||
end
|
||||
end
|
||||
|
||||
describe '.federal_supervisors' do
|
||||
let!(:relationship1) { create :supporter_relationship }
|
||||
let!(:relationship2) { create :member_relationship }
|
||||
let!(:relationship3) { create :excluded_supporter_relationship }
|
||||
let!(:relationship3) { create :excluded_member_relationship }
|
||||
let!(:relationship4) { create :federal_manager_relationship }
|
||||
let!(:relationship5) { create :federal_supervisor_relationship }
|
||||
let!(:relationship6) { create :regional_manager_relationship }
|
||||
let!(:relationship7) { create :regional_supervisor_relationship }
|
||||
let!(:relationship8) { create :federal_supervisor_relationship }
|
||||
|
||||
specify do
|
||||
expect(described_class.federal_supervisors).to \
|
||||
eq [relationship5, relationship8]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue