merge admin api tokens
This commit is contained in:
parent
8898d44961
commit
faecefe405
2 changed files with 14 additions and 0 deletions
|
@ -139,6 +139,10 @@ class Administrateur < ApplicationRecord
|
|||
i.administrateurs << self
|
||||
i.administrateurs.delete(old_admin)
|
||||
end
|
||||
|
||||
old_admin.api_tokens.each do |token|
|
||||
self.api_tokens << token
|
||||
end
|
||||
end
|
||||
|
||||
def zones
|
||||
|
|
|
@ -166,6 +166,16 @@ describe Administrateur, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the old admin has an api token' do
|
||||
let(:old_admin) { create(:administrateur, :with_api_token) }
|
||||
|
||||
it 'transferts the api token' do
|
||||
subject
|
||||
expect(new_admin.api_tokens.count).to eq 1
|
||||
expect(new_admin.api_tokens.first).to eq old_admin.api_tokens.first
|
||||
end
|
||||
end
|
||||
|
||||
context 'when both admins share an instructeur' do
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue