osem-fcy/spec/controllers/confirmations_controller_spec.rb
Ana María Martínez Gómez d1180e2767
Use keyword arguments in tests
Raisl 5.1 removes support for non-keyword arguments in `#process`,
`#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head` for the
`ActionDispatch::IntegrationTest` and `ActionController::TestCase`
classes. This means we have to add `params` everywhere in the controller
tests.
2019-05-14 14:10:36 +02:00

30 lines
730 B
Ruby

# frozen_string_literal: true
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, params: { 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, params: { confirmation_token: user.confirmation_token }
user.reload
expect(user.confirmed?).to eq true
end
end
end