Sha256: 5b3ed492cc234f89f05ccc38ac355101a37110fcedfcd0f4fb800636652abe0b

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'test_helper'

class CompanyUserSessionStoriesTest < ActionController::IntegrationTest
  def setup
    super
    self.scope = Company.first
  end
  
  def test_login_process
    # Try to access the company account area without being logged in
    get scoped_url("account_url")
    assert_redirected_to scoped_url("new_user_session_url")
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "user_sessions/new"
    
    # Try to login unsuccessfully
    assert_unsuccessful_login
    assert_unsuccessful_login("bjohnson", "badpassword")
    assert_unsuccessful_login("zham", "zackrocks") # this is correct, but zack does not belong to this company
    
    assert_successful_login("bjohnson", "benrocks")
    
    # Try to log in again after a successful login
    get scoped_url("new_user_session_url")
    assert_redirected_to scoped_url("account_url")
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    # Try to register after a successful login
    get scoped_url("new_account_url")
    assert_redirected_to scoped_url("account_url")
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    assert_account_access
    assert_successful_logout(scoped_url("new_account_url")) # before I tried to register, it stored my location
    
    # Try to access my account again
    get scoped_url("account_url")
    assert_redirected_to scoped_url("new_user_session_url")
    assert flash.key?(:notice)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-0.10.4 test_app/test/integration/company_user_session_stories_test.rb