mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Got another bunch of tests passing with MongoMapper.
This commit is contained in:
parent
0819f87255
commit
78303cd5c5
11 changed files with 39 additions and 22 deletions
|
@ -18,3 +18,4 @@ en:
|
|||
confirmation_instructions: 'Confirmation instructions'
|
||||
reset_password_instructions: 'Reset password instructions'
|
||||
|
||||
|
||||
|
|
|
@ -114,9 +114,15 @@ module Devise
|
|||
|
||||
if value.present?
|
||||
record.send(:"#{attribute}=", value)
|
||||
record.errors.add(attribute, error, :default => error.to_s.gsub("_", " "))
|
||||
options = { :default => error.to_s.gsub("_", " ") }
|
||||
else
|
||||
record.errors.add(attribute, :blank)
|
||||
error, options = :blank, {}
|
||||
end
|
||||
|
||||
begin
|
||||
record.errors.add(attribute, error, options)
|
||||
rescue ArgumentError
|
||||
record.errors.add(attribute, error.to_s.gsub("_", " "))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class RememberableTest < ActiveSupport::TestCase
|
|||
test 'valid remember token should also verify if remember is not expired' do
|
||||
user = create_user
|
||||
user.remember_me!
|
||||
user.update_attribute(:remember_created_at, 3.days.ago)
|
||||
user.update_attributes(:remember_created_at => 3.days.ago)
|
||||
assert_not user.valid_remember_token?(user.remember_token)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'test/test_helper'
|
||||
|
||||
class ValidatableTest < ActiveSupport::TestCase
|
||||
extend Devise::TestSilencer if [:mongo_mapper, :data_mapper].include?(DEVISE_ORM)
|
||||
|
||||
test 'should require email to be set' do
|
||||
user = new_user(:email => nil)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
||||
require 'test_help'
|
||||
|
||||
ActiveRecord::Migration.verbose = false
|
||||
ActiveRecord::Base.logger = Logger.new(nil)
|
||||
|
@ -22,7 +23,6 @@ ActiveRecord::Schema.define(:version => 1) do
|
|||
end
|
||||
end
|
||||
|
||||
require 'test_help'
|
||||
class ActiveSupport::TestCase
|
||||
self.use_transactional_fixtures = true
|
||||
self.use_instantiated_fixtures = false
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
require 'mongo_mapper'
|
||||
MongoMapper.database = "devise-test-suite"
|
||||
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
||||
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
||||
|
||||
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
||||
require 'test_help'
|
||||
|
||||
module MongoMapper::Document
|
||||
# TODO This should not be required
|
||||
def invalid?
|
||||
!valid?
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
setup do
|
||||
User.delete_all
|
||||
|
|
|
@ -4,6 +4,6 @@ class Admin
|
|||
devise :all, :timeoutable, :except => [:recoverable, :confirmable, :rememberable, :validatable, :trackable]
|
||||
|
||||
def self.find_for_authentication(conditions)
|
||||
last(:conditions => conditions)
|
||||
last(:conditions => conditions, :order => "email")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class User
|
||||
include MongoMapper::Document
|
||||
key :created_at, DateTime
|
||||
devise :all, :timeoutable
|
||||
# attr_accessible :username, :email, :password, :password_confirmation
|
||||
end
|
||||
|
|
|
@ -19,4 +19,19 @@ class ActiveSupport::TestCase
|
|||
def assert_email_not_sent(&block)
|
||||
assert_no_difference('ActionMailer::Base.deliveries.size') { yield }
|
||||
end
|
||||
|
||||
# Execute the block setting the given values and restoring old values after
|
||||
# the block is executed.
|
||||
def swap(object, new_values)
|
||||
old_values = {}
|
||||
new_values.each do |key, value|
|
||||
old_values[key] = object.send key
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
old_values.each do |key, value|
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ class ActiveSupport::TestCase
|
|||
|
||||
def valid_attributes(attributes={})
|
||||
{ :email => generate_unique_email,
|
||||
:created_at => Time.now.utc,
|
||||
:password => '123456',
|
||||
:password_confirmation => '123456' }.update(attributes)
|
||||
end
|
||||
|
@ -33,19 +34,4 @@ class ActiveSupport::TestCase
|
|||
def create_user(attributes={})
|
||||
User.create!(valid_attributes(attributes))
|
||||
end
|
||||
|
||||
# Execute the block setting the given values and restoring old values after
|
||||
# the block is executed.
|
||||
def swap(object, new_values)
|
||||
old_values = {}
|
||||
new_values.each do |key, value|
|
||||
old_values[key] = object.send key
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
old_values.each do |key, value|
|
||||
object.send :"#{key}=", value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,6 +56,6 @@ class TestHelpersTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def create_user(i=nil)
|
||||
User.create!(:email => "jose.valim#{i}@plataformatec.com", :password => "123456")
|
||||
super(:email => "jose.valim#{i}@plataformatec.com")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue