mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #950 from sonalkr132/confirmation-test
Add devise confirmation controller test
This commit is contained in:
commit
ecac90c268
1 changed files with 28 additions and 0 deletions
28
spec/controllers/confirmations_controller_spec.rb
Normal file
28
spec/controllers/confirmations_controller_spec.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ConfirmationsController do
|
||||
let(:user) { create(:user, confirmed_at: nil) }
|
||||
|
||||
before do
|
||||
@request.env['devise.mapping'] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
context 'user is not signed in' do
|
||||
it 'confirms and signs in user' do
|
||||
get :show, confirmation_token: user.confirmation_token
|
||||
user.reload
|
||||
expect(user.confirmed?).to eq true
|
||||
expect(controller.current_user).to eq user
|
||||
end
|
||||
end
|
||||
|
||||
context 'user is signed in' do
|
||||
before { sign_in user }
|
||||
|
||||
it 'confirms user' do
|
||||
get :show, confirmation_token: user.confirmation_token
|
||||
user.reload
|
||||
expect(user.confirmed?).to eq true
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue