2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-04-07 17:22:10 +05:30
|
|
|
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
|
2019-05-13 17:42:09 +02:00
|
|
|
get :show, params: { confirmation_token: user.confirmation_token }
|
2016-04-07 17:22:10 +05:30
|
|
|
user.reload
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(user.confirmed?).to be true
|
2016-04-07 17:22:10 +05:30
|
|
|
expect(controller.current_user).to eq user
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'user is signed in' do
|
|
|
|
|
before { sign_in user }
|
|
|
|
|
|
|
|
|
|
it 'confirms user' do
|
2019-05-13 17:42:09 +02:00
|
|
|
get :show, params: { confirmation_token: user.confirmation_token }
|
2016-04-07 17:22:10 +05:30
|
|
|
user.reload
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(user.confirmed?).to be true
|
2016-04-07 17:22:10 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|