Sha256: 9ba0d9256053eb01f22bf685402516a90cd0e3e3fc7d605c553b936430930805

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

require 'test/test_helper'

class Invitable < ActiveRecord::Base
  set_table_name 'users'
  devise :database_authenticatable, :invitable, :encryptable, :invite_for => 5.days
end

class ModelsTest < ActiveSupport::TestCase
  def include_module?(klass, mod)
    klass.devise_modules.include?(mod) &&
    klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
  end

  def assert_include_modules(klass, *modules)
    modules.each do |mod|
      assert include_module?(klass, mod), "#{klass} not include #{mod}"
    end
  end

  test 'add invitable module only' do
    assert_include_modules Invitable, :invitable
  end

  test 'set a default value for invite_for' do
    assert_equal 5.days, Invitable.invite_for
  end

  test 'invitable attributes' do
    assert_not_nil Invitable.columns_hash['invitation_token']
    assert_not_nil Invitable.columns_hash['invitation_sent_at']
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
dougjohnston-devise_invitable-0.4.rc test/models_test.rb
aihs_devise_invitable-0.4.rc test/models_test.rb