Skip to content

Commit

Permalink
More compatibility with Rails master.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Mar 28, 2010
1 parent 6bcf18b commit ea71be8
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
@@ -0,0 +1,2 @@
---
BUNDLE_WITHOUT: ""
4 changes: 2 additions & 2 deletions lib/devise.rb
Expand Up @@ -60,8 +60,8 @@ module Encryptors
@@password_length = 6..20

# Email regex used to validate email formats. Adapted from authlogic.
mattr_accessor :email_regex
@@email_regex = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
mattr_accessor :email_regexp
@@email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i

# Time interval where the remember me token is valid.
mattr_accessor :remember_for
Expand Down
2 changes: 1 addition & 1 deletion lib/devise/models/validatable.rb
Expand Up @@ -16,7 +16,7 @@ def self.included(base)
base.class_eval do
validates_presence_of :email
validates_uniqueness_of :email, :scope => authentication_keys[1..-1], :allow_blank => true
validates_format_of :email, :with => Devise.email_regex, :allow_blank => true
validates_format_of :email, :with => Devise.email_regexp, :allow_blank => true

with_options :if => :password_required? do |v|
v.validates_presence_of :password
Expand Down
6 changes: 5 additions & 1 deletion lib/devise/orm/data_mapper.rb
Expand Up @@ -76,7 +76,11 @@ def find(*args)
def changed?
dirty?
end


def new_record?
new?
end

def save(options=nil)
if options.is_a?(Hash) && options[:validate] == false
save
Expand Down
2 changes: 0 additions & 2 deletions lib/devise/rails.rb
Expand Up @@ -3,8 +3,6 @@

module Devise
class Engine < ::Rails::Engine
engine_name :devise

initializer "devise.add_middleware" do |app|
app.config.middleware.use Warden::Manager do |config|
Devise.configure_warden(config)
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/devise_install/templates/devise.rb
Expand Up @@ -43,7 +43,7 @@
# config.password_length = 6..20

# Regex to use to validate the email address
# config.email_regex = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i

# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
Expand Down
3 changes: 0 additions & 3 deletions test/orm/active_record.rb
@@ -1,6 +1,3 @@
require File.expand_path('../../rails_app/config/environment', __FILE__)
require 'rails/test_help'

ActiveRecord::Migration.verbose = false
ActiveRecord::Base.logger = Logger.new(nil)

Expand Down
3 changes: 0 additions & 3 deletions test/orm/data_mapper.rb
@@ -1,4 +1 @@
require File.expand_path('../../rails_app/config/environment', __FILE__)
require 'rails/test_help'

DataMapper.auto_migrate!
7 changes: 0 additions & 7 deletions test/orm/mongoid.rb
@@ -1,14 +1,7 @@
require File.expand_path('../../rails_app/config/environment', __FILE__)
require 'rails/test_help'

Mongoid.configure do |config|
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("devise-test-suite")
end

I18n.load_path << File.join(
File.dirname(__FILE__), "mongoid", "locale", "en.yml"
)

class ActiveSupport::TestCase
setup do
User.delete_all
Expand Down
4 changes: 4 additions & 0 deletions test/rails_app/config/application.rb
Expand Up @@ -28,5 +28,9 @@ class Application < Rails::Application

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters << :password

# Cookie settings
config.cookie_secret = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
config.session_store :cookie_store, :key => "_my_app"
end
end
2 changes: 1 addition & 1 deletion test/rails_app/config/boot.rb
Expand Up @@ -3,7 +3,7 @@
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.setup :default, DEVISE_ORM
end

$:.unshift File.expand_path('../../../../lib', __FILE__)

This file was deleted.

15 changes: 0 additions & 15 deletions test/rails_app/config/initializers/session_store.rb

This file was deleted.

File renamed without changes.
7 changes: 5 additions & 2 deletions test/test_helper.rb
@@ -1,11 +1,14 @@
ENV["RAILS_ENV"] = "test"
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym

$:.unshift File.dirname(__FILE__)
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"

require File.expand_path('../rails_app/config/application', __FILE__)
require File.expand_path("../orm/#{DEVISE_ORM}", __FILE__)
require "rails_app/config/environment"
require "rails/test_help"
require "orm/#{DEVISE_ORM}"

I18n.load_path << File.expand_path("../support/locale/en.yml", __FILE__)
require 'mocha'

ActionMailer::Base.delivery_method = :test
Expand Down

0 comments on commit ea71be8

Please sign in to comment.