Api Token: do not generate one token by default

This commit is contained in:
simon lehericey 2018-08-24 15:53:57 +02:00
parent 17285b0368
commit 1997f45d7e
7 changed files with 55 additions and 33 deletions

View file

@ -8,27 +8,6 @@ describe Administrateur, type: :model do
it { is_expected.to have_many(:procedures) }
end
describe 'after_save' do
subject { create(:administrateur) }
before do
subject.save
end
it { expect(subject.api_token).not_to be_blank }
end
describe 'generate_api_token' do
let(:token) { 'bullshit' }
let(:new_token) { 'pocket_master' }
let!(:admin_1) { create(:administrateur, api_token: token) }
before do
allow(SecureRandom).to receive(:hex).and_return(token, new_token)
admin_1.renew_api_token
end
it 'generate a token who does not already exist' do
expect(admin_1.api_token).to eq(new_token)
end
end
context 'unified login' do
it 'syncs credentials to associated user' do
administrateur = create(:administrateur)