Retrospring/spec/controllers/user/sessions_controller_spec.rb

25 lines
701 B
Ruby
Raw Normal View History

require 'rails_helper'
describe User::SessionsController do
before do
2020-10-23 11:45:06 -07:00
# Required for devise to register routes
@request.env["devise.mapping"] = Devise.mappings[:user]
end
2020-10-20 02:44:20 -07:00
describe "#create" do
let(:user) { FactoryBot.create(:user, password: '/bin/animals64') }
subject { post :create, params: { user: { login: user.email, password: user.password } } }
it "logs in users without 2FA enabled without any further input" do
expect(subject).to redirect_to :root
end
it "prompts users with 2FA enabled to enter a code" do
user.otp_module = :enabled
user.save
2020-10-23 11:45:06 -07:00
expect(subject).to have_rendered('auth/two_factor_authentication')
2020-10-20 02:44:20 -07:00
end
end
end