Sha256: 1ec42eb4db00a77afd4f4b412f065a0ad838875f96e13f013e53626176d2e86b

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

RSpec.feature 'Sign In', type: :feature do
  background do
    @user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret')
    visit spree.login_path
  end

  scenario 'ask user to sign in' do
    visit spree.admin_path
    expect(page).not_to have_text 'Authorization Failure'
  end

  scenario 'let a user sign in successfully', js: true do
    log_in(email: @user.email, password: @user.password)
    show_user_menu

    expect(page).not_to have_text 'Login'
    expect(page).to have_text 'LOG OUT'
    expect(current_path).to eq '/account'
  end

  scenario 'show validation erros' do
    fill_in 'Email', with: @user.email
    fill_in 'Password', with: 'wrong_password'
    click_button 'Log in'

    expect(page).to have_text 'Invalid email or password'
    expect(page).to have_text 'Log in'
  end

  scenario 'allow a user to access a restricted page after logging in' do
    user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password')
    visit spree.admin_path

    fill_in 'Email', with: user.email
    fill_in 'Password', with: user.password
    click_button 'Log in'

    if Spree.version.to_f > 4.1
      within '.navbar .dropdown-menu' do
        expect(page).to have_text 'admin@person.com'
      end
    else
      within '.user-menu' do
        expect(page).to have_text 'admin@person.com'
      end
    end
    expect(current_path).to eq '/admin/orders'
  end

  it 'should store the user previous location' do
    visit spree.account_path
    fill_in 'Email', with: @user.email
    fill_in 'Password', with: @user.password
    click_button 'Log in'
    expect(current_path).to eq '/account'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth_devise-4.2.1 spec/features/sign_in_spec.rb
spree_auth_devise-4.3.2 spec/features/sign_in_spec.rb
spree_auth_devise-4.3.1 spec/features/sign_in_spec.rb
spree_auth_devise-4.3.0 spec/features/sign_in_spec.rb
spree_auth_devise-4.2.0 spec/features/sign_in_spec.rb