Sha256: eeb5fc7e29dc6f7254bf5036df971c91abd1d609546f2451bd1c7133dfc5b9ca

Contents?: true

Size: 1.91 KB

Versions: 17

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe 'Login' do
  include CASino::Engine.routes.url_helpers

  subject { page }

  context 'with two-factor authentication enabled' do
    before do
      in_browser(:other) do
        sign_in
        @totp = enable_two_factor_authentication
      end
    end

    context 'with valid username and password' do
      before { sign_in }

      it { should_not have_button('Login') }
      it { should have_button('Continue') }
      its(:current_path) { should == login_path }

      context 'when filling in the correct otp' do
        before do
          fill_in :otp, with: @totp.now
          click_button 'Continue'
        end

        it { should_not have_button('Login') }
        it { should_not have_button('Continue') }
        its(:current_path) { should == sessions_path }
      end

      context 'when filling in an incorrect otp' do
        before do
          fill_in :otp, with: 'aaaaa'
          click_button 'Continue'
        end

        it { should have_text('The one-time password you entered is not correct') }
        it { should have_button('Continue') }
      end
    end
  end

  context 'with two-factor authentication disabled' do
    context 'with valid username and password' do
      before { sign_in }

      it { should_not have_button('Login') }
      its(:current_path) { should == sessions_path }
    end
  end

  context 'with invalid username' do
    before { sign_in username: 'lalala', password: 'foobar123' }

    it { should have_button('Login') }
    it { should have_text('Incorrect username or password') }
  end

  context 'with blank password' do
    before { sign_in password: '' }

    it { should have_button('Login') }
    it { should have_text('Incorrect username or password') }
  end

  context 'with german locale' do
    before do
      page.driver.header 'Accept-Language', 'de'
      visit login_path
    end

    it { should have_text('Benutzername') }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
casino-3.0.4 spec/features/login_spec.rb
casino-2.0.7 spec/features/login_spec.rb
casino-3.0.3 spec/features/login_spec.rb
casino-3.0.2 spec/features/login_spec.rb
casino-3.0.1 spec/features/login_spec.rb
casino-3.0.0 spec/features/login_spec.rb
casino-3.0.0.pre.2 spec/features/login_spec.rb
casino-3.0.0.pre.1 spec/features/login_spec.rb
casino-2.0.6 spec/features/login_spec.rb
casino-2.0.5 spec/features/login_spec.rb
casino-2.0.4 spec/features/login_spec.rb
casino-2.0.3 spec/features/login_spec.rb
casino-2.0.2 spec/features/login_spec.rb
casino-2.0.1 spec/features/login_spec.rb
casino-2.0.0 spec/features/login_spec.rb
casino-1.3.2 spec/features/login_spec.rb
casino-1.3.1 spec/features/login_spec.rb