Sha256: e8ab3540b67ff7dcac94c3981b6bd72d37b1f1779185eddb01024069172c895d

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

describe Devise::TwoFactorAuthenticationController, type: :controller do
  describe '#is_fully_authenticated?' do
    def post_code(code)
      if Rails::VERSION::MAJOR >= 5
        post :update, params: { code: code }
      else
        post :update, code: code
      end
    end

    before do
      sign_in
    end

    context 'after user enters valid OTP code' do
      it 'returns true' do
        controller.current_user.send_new_otp
        post_code controller.current_user.direct_otp
        expect(subject.is_fully_authenticated?).to eq true
      end
    end

    context 'when user has not entered any OTP yet' do
      it 'returns false' do
        get :show

        expect(subject.is_fully_authenticated?).to eq false
      end
    end

    context 'when user enters an invalid OTP' do
      it 'returns false' do
        post_code '12345'

        expect(subject.is_fully_authenticated?).to eq false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise-multi-factor-3.2.5 spec/controllers/two_factor_authentication_controller_spec.rb
devise-multi-factor-3.2.4 spec/controllers/two_factor_authentication_controller_spec.rb
devise-multi-factor-3.2.3 spec/controllers/two_factor_authentication_controller_spec.rb
devise-multi-factor-3.2.2 spec/controllers/two_factor_authentication_controller_spec.rb
devise-multi-factor-3.2.1 spec/controllers/two_factor_authentication_controller_spec.rb
devise-multi-factor-3.2.0 spec/controllers/two_factor_authentication_controller_spec.rb