get zones of an admin
This commit is contained in:
parent
9260c084d3
commit
f9f31b721a
2 changed files with 15 additions and 0 deletions
|
@ -148,6 +148,10 @@ class Administrateur < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def zones
|
||||
procedures.joins(:zones).flat_map(&:zones).uniq
|
||||
end
|
||||
|
||||
# required to display feature flags field in manager
|
||||
def features
|
||||
end
|
||||
|
|
|
@ -213,4 +213,15 @@ describe Administrateur, type: :model do
|
|||
it { is_expected.to be_empty }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'zones' do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:zone1) { create(:zone) }
|
||||
let(:zone2) { create(:zone) }
|
||||
let!(:procedure) { create(:procedure, administrateurs: [admin], zones: [zone1, zone2]) }
|
||||
|
||||
it 'return zones of procedures that the admin is associated' do
|
||||
expect(admin.zones).to eq [zone1, zone2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue