2011-02-10 03:10:04 -05:00
|
|
|
if DEVISE_ORM == :mongoid
|
2011-02-09 22:51:19 -05:00
|
|
|
|
2011-02-10 03:10:04 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class User2
|
|
|
|
include Mongoid::Document
|
|
|
|
devise :database_authenticatable
|
|
|
|
end
|
|
|
|
|
|
|
|
class User3
|
|
|
|
include Mongoid::Document
|
|
|
|
devise :database_authenticatable, :authentication_keys => [:username, :email]
|
|
|
|
end
|
|
|
|
|
|
|
|
class User4
|
|
|
|
include Mongoid::Document
|
|
|
|
devise :database_authenticatable, :authentication_keys => [:username]
|
|
|
|
end
|
|
|
|
|
|
|
|
class SchemaTest < ActiveSupport::TestCase
|
2011-02-09 22:51:19 -05:00
|
|
|
test 'should create an email field if there are no custom authentication keys' do
|
|
|
|
assert_not_equal User2.fields['email'], nil
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'should create an email field if there are custom authentication keys and they include email' do
|
|
|
|
assert_not_equal User3.fields['email'], nil
|
|
|
|
end
|
2011-02-10 03:10:04 -05:00
|
|
|
|
2011-02-09 22:51:19 -05:00
|
|
|
test 'should not create an email field if there are custom authentication keys they don\'t include email' do
|
|
|
|
assert_equal User4.fields['email'], nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|