Sha256: 3caa82e5f0383d237a83cd670f589bd385ba95f346e3c601edada73d5b27e5fc

Contents?: true

Size: 993 Bytes

Versions: 8

Compression:

Stored size: 993 Bytes

Contents

require 'test/test_helper'

class Invitable < User
  devise :authenticatable, :invitable, :invite_for => 5.days
end

class ActiveRecordTest < 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

    (Devise::ALL - modules).each do |mod|
      assert_not include_module?(klass, mod), "#{klass} include #{mod}"
    end
  end

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

  test 'set a default value for invit_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

8 entries across 8 versions & 1 rubygems

Version Path
devise_invitable-0.2.2 test/models_test.rb
devise_invitable-0.2.1 test/models_test.rb
devise_invitable-0.2.0 test/models_test.rb
devise_invitable-0.1.4 test/models_test.rb
devise_invitable-0.1.3 test/models_test.rb
devise_invitable-0.1.2 test/models_test.rb
devise_invitable-0.1.1 test/models_test.rb
devise_invitable-0.1.0 test/models_test.rb