Sha256: 173031ee2a9db209d78b12e99fabaded57775ce0e359c8e411d5ebb90e56b9d2

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
require 'features/acceptance_helper'

feature 'Devise Sign-in' do
  background do
    Setting.user_signup = :needs_approval
    @user = create :user,
                   username: 'john',
                   password: 'password',
                   password_confirmation: 'password',
                   email: 'john@example.com',
                   sign_in_count: 0
  end

  scenario 'without confirmation' do
    login_process('john', 'password')
    expect(page).to have_content("You have to confirm your email address before continuing.")
  end

  scenario 'without approval' do
    @user.confirm
    login_process('john', 'password')
    expect(page).to have_content("Your account has not been approved yet.")
  end

  scenario 'with approved and confirmed account' do
    @user.confirm
    @user.update_attribute(:suspended_at, nil)
    login_process('john', 'password')
    expect(page).to have_content("Signed in successfully.")
  end

  scenario 'invalid credentials' do
    login_process('jo', 'pass')
    expect(current_path).to eq "/users/sign_in"
    expect(page).to have_content("Invalid Email or password")
  end

  scenario 'login with email' do
    @user.confirm
    @user.update_attribute(:suspended_at, nil)
    login_process('john@example.com', 'password')
    expect(page).to have_content("Signed in successfully")
  end

  def login_process(username, password)
    visit '/users/sign_in'
    fill_in 'user[email]', with: username
    fill_in 'user[password]', with: password
    click_button 'Login'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fat_free_crm-0.20.1 spec/features/devise/sign_in_spec.rb
fat_free_crm-0.20.0 spec/features/devise/sign_in_spec.rb
fat_free_crm-0.19.2 spec/features/devise/sign_in_spec.rb
fat_free_crm-0.19.0 spec/features/devise/sign_in_spec.rb