ActivateController: add tests and clean a bit
This commit is contained in:
parent
d5ddd182a7
commit
58ecf18390
2 changed files with 25 additions and 16 deletions
|
@ -17,4 +17,24 @@ describe Users::ActivateController, type: :controller do
|
|||
it { expect(controller).not_to have_received(:trust_device) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
let!(:user) { create(:user) }
|
||||
let(:token) { user.send(:set_reset_password_token) }
|
||||
let(:password) { 'another-password-ok?' }
|
||||
|
||||
before { post :create, params: { user: { reset_password_token: token, password: password } } }
|
||||
|
||||
context 'when the token is ok' do
|
||||
it { expect(user.reload.valid_password?(password)).to be true }
|
||||
it { expect(response).to redirect_to(instructeur_procedures_path) }
|
||||
end
|
||||
|
||||
context 'when the token is bad' do
|
||||
let(:token) { 'bad' }
|
||||
|
||||
it { expect(user.reload.valid_password?(password)).to be false }
|
||||
it { expect(response).to redirect_to(users_activate_path(token: token)) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue