merge only v3 api tokens
This commit is contained in:
parent
faecefe405
commit
18f5c2a9ad
2 changed files with 14 additions and 3 deletions
|
@ -140,7 +140,7 @@ class Administrateur < ApplicationRecord
|
|||
i.administrateurs.delete(old_admin)
|
||||
end
|
||||
|
||||
old_admin.api_tokens.each do |token|
|
||||
old_admin.api_tokens.where('version >= ?', 3).find_each do |token|
|
||||
self.api_tokens << token
|
||||
end
|
||||
end
|
||||
|
|
|
@ -166,13 +166,24 @@ describe Administrateur, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the old admin has an api token' do
|
||||
context 'when the old admin has an v3 api token' do
|
||||
let(:old_admin) { create(:administrateur, :with_api_token) }
|
||||
|
||||
it 'transferts the api token' do
|
||||
token = old_admin.api_tokens.first
|
||||
subject
|
||||
expect(new_admin.api_tokens.count).to eq 1
|
||||
expect(new_admin.api_tokens.first).to eq old_admin.api_tokens.first
|
||||
expect(new_admin.api_tokens.first).to eq token
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the old admin has an old api token' do
|
||||
let(:old_admin) { create(:administrateur, :with_api_token) }
|
||||
|
||||
it 'does not transfer the api token' do
|
||||
old_admin.api_tokens.first.update(version: 2)
|
||||
subject
|
||||
expect(new_admin.api_tokens.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue