Sha256: 1d6f4f2d728034625119059d96aacd11d2e3b6affc8df2c69db0151dc812e544

Contents?: true

Size: 1.41 KB

Versions: 15

Compression:

Stored size: 1.41 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")

class AnonymousTest < ActiveSupport::TestCase
  def setup
    super
    @anonymous = User.anonymous :name => 'John Doe'
  end

  test 'acts as authenticated user (with single token authentication)' do
    User.should act_as_authenticated_user
  end

  # VALIDATIONS

  test 'validates the presence of a name' do
    @anonymous.should validate_presence_of(:first_name)
  end

  test 'validates the presence of an email' do
    @anonymous.should validate_presence_of(:email)
  end

  test 'validates the length of the name (3-40 chars)' do
    @anonymous.should validate_length_of(:first_name, :within => 3..40)
  end

  test 'email format validation succeeds with a valid email address' do
    @anonymous.email = 'valid@email.org'
    @anonymous.should be_valid
  end

  test 'email format validation fails with an invalid email address' do
    @anonymous.email = 'invalid-email.org'
    @anonymous.should_not be_valid
  end

  # INSTANCE METHODS

  test '#has_role? returns true when the passed role is Role::Anonymous' do
    @anonymous.should have_role(:anonymous)
  end

  test '#has_role? returns false when the passed role is not Role::Anonymous' do
    @anonymous.should_not have_role(:user)
  end

  test '#anonymous? returns true' do
    @anonymous.should be_anonymous
  end

  test '#registered? returns false' do
    @anonymous.should_not be_registered
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 test/unit/models/anonymous_test.rb
adva-0.3.1 test/unit/models/anonymous_test.rb
adva-0.3.0 test/unit/models/anonymous_test.rb
adva-0.2.4 test/unit/models/anonymous_test.rb
adva-0.2.3 test/unit/models/anonymous_test.rb
adva-0.2.2 test/unit/models/anonymous_test.rb
adva-0.2.1 test/unit/models/anonymous_test.rb
adva-0.2.0 test/unit/models/anonymous_test.rb
adva-0.1.4 test/unit/models/anonymous_test.rb
adva-0.1.3 test/unit/models/anonymous_test.rb
adva-0.1.2 test/unit/models/anonymous_test.rb
adva-0.1.1 test/unit/models/anonymous_test.rb
adva-0.1.0 test/unit/models/anonymous_test.rb
adva_user-0.0.1 test/unit/models/anonymous_test.rb
adva-0.0.1 adva_user/test/unit/models/anonymous_test.rb