invite: move invites link to the after_confirmation callback

Refactored from 6a69d958da

The `after_confirmation_path_for` isn't really made to be a callbback.
For instance, it is not executed during tests.

Moving the invitations linking to a proper documented callback allows
the linking to work in a testing environment, when invoking `user.confirm`.
This commit is contained in:
Pierre de La Morinerie 2018-09-19 09:56:05 +00:00
parent cceb88539d
commit 082ef92a99
5 changed files with 31 additions and 63 deletions

View file

@ -1,6 +1,25 @@
require 'spec_helper'
describe User, type: :model do
describe '#after_confirmation' do
let(:email) { 'mail@beta.gouv.fr' }
let!(:invite) { create(:invite, email: email) }
let!(:invite2) { create(:invite, email: email) }
let(:user) do
create(:user,
email: email,
password: 'a good password',
confirmation_token: '123',
confirmed_at: nil)
end
it 'when confirming a user, it links the pending invitations to this user' do
expect(user.invites.size).to eq(0)
user.confirm
expect(user.reload.invites.size).to eq(2)
end
end
describe '#find_for_france_connect' do
let(:siret) { '00000000000000' }
context 'when user exist' do