Fix spec failures for Mongoid 3.
This has no actual changes to Devise itself, just fixes the failing tests when running against Mongoid 3 instead of Mongoid 2. Mocha has been locked at 0.10.0 since 0.12.0 raises an error when trying to set an expectation on a frozen object. Tests were updated to work with both AR and Mongoid, some cases the XML serialization was slightly different but both were outputting correct and valid XML, and the id/_id field mismatch is now handled. An active field was missing from the test models for Mongoid, and the invalid :null => true options in field were removed.
This commit is contained in:
parent
b1df686a2e
commit
d821275588
6
Gemfile
6
Gemfile
|
@ -11,7 +11,7 @@ group :test do
|
||||||
gem "omniauth-facebook"
|
gem "omniauth-facebook"
|
||||||
gem "omniauth-openid", "~> 1.0.1"
|
gem "omniauth-openid", "~> 1.0.1"
|
||||||
gem "webrat", "0.7.2", :require => false
|
gem "webrat", "0.7.2", :require => false
|
||||||
gem "mocha", :require => false
|
gem "mocha", "0.10.0", :require => false
|
||||||
end
|
end
|
||||||
|
|
||||||
platforms :jruby do
|
platforms :jruby do
|
||||||
|
@ -24,8 +24,6 @@ platforms :ruby do
|
||||||
gem "sqlite3"
|
gem "sqlite3"
|
||||||
|
|
||||||
group :mongoid do
|
group :mongoid do
|
||||||
gem "mongo", "~> 1.3.0"
|
gem "mongoid", "~> 3.0"
|
||||||
gem "mongoid", "~> 2.0"
|
|
||||||
gem "bson_ext", "~> 1.3.0"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
124
Gemfile.lock
124
Gemfile.lock
|
@ -10,81 +10,83 @@ PATH
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (3.2.6)
|
actionmailer (3.2.8)
|
||||||
actionpack (= 3.2.6)
|
actionpack (= 3.2.8)
|
||||||
mail (~> 2.4.4)
|
mail (~> 2.4.4)
|
||||||
actionpack (3.2.6)
|
actionpack (3.2.8)
|
||||||
activemodel (= 3.2.6)
|
activemodel (= 3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
builder (~> 3.0.0)
|
builder (~> 3.0.0)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
journey (~> 1.0.1)
|
journey (~> 1.0.4)
|
||||||
rack (~> 1.4.0)
|
rack (~> 1.4.0)
|
||||||
rack-cache (~> 1.2)
|
rack-cache (~> 1.2)
|
||||||
rack-test (~> 0.6.1)
|
rack-test (~> 0.6.1)
|
||||||
sprockets (~> 2.1.3)
|
sprockets (~> 2.1.3)
|
||||||
activemodel (3.2.6)
|
activemodel (3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
builder (~> 3.0.0)
|
builder (~> 3.0.0)
|
||||||
activerecord (3.2.6)
|
activerecord (3.2.8)
|
||||||
activemodel (= 3.2.6)
|
activemodel (= 3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
arel (~> 3.0.2)
|
arel (~> 3.0.2)
|
||||||
tzinfo (~> 0.3.29)
|
tzinfo (~> 0.3.29)
|
||||||
activeresource (3.2.6)
|
activeresource (3.2.8)
|
||||||
activemodel (= 3.2.6)
|
activemodel (= 3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
activesupport (3.2.6)
|
activesupport (3.2.8)
|
||||||
i18n (~> 0.6)
|
i18n (~> 0.6)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
addressable (2.2.6)
|
|
||||||
arel (3.0.2)
|
arel (3.0.2)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
bson (1.5.1)
|
builder (3.0.4)
|
||||||
bson_ext (1.3.1)
|
|
||||||
builder (3.0.0)
|
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
faraday (0.7.5)
|
faraday (0.8.4)
|
||||||
addressable (~> 2.2.6)
|
multipart-post (~> 1.1)
|
||||||
multipart-post (~> 1.1.3)
|
|
||||||
rack (>= 1.1.0, < 2)
|
|
||||||
hashie (1.2.0)
|
hashie (1.2.0)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
i18n (0.6.0)
|
httpauth (0.2.0)
|
||||||
|
i18n (0.6.1)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
json (1.7.3)
|
json (1.7.5)
|
||||||
|
jwt (0.1.5)
|
||||||
|
multi_json (>= 1.0)
|
||||||
mail (2.4.4)
|
mail (2.4.4)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
metaclass (0.0.1)
|
metaclass (0.0.1)
|
||||||
mime-types (1.18)
|
mime-types (1.19)
|
||||||
mocha (0.10.0)
|
mocha (0.10.0)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
mongo (1.3.1)
|
mongoid (3.0.11)
|
||||||
bson (>= 1.3.1)
|
|
||||||
mongoid (2.3.4)
|
|
||||||
activemodel (~> 3.1)
|
activemodel (~> 3.1)
|
||||||
mongo (~> 1.3)
|
moped (~> 1.1)
|
||||||
|
origin (~> 1.0)
|
||||||
tzinfo (~> 0.3.22)
|
tzinfo (~> 0.3.22)
|
||||||
multi_json (1.0.4)
|
moped (1.2.8)
|
||||||
multipart-post (1.1.4)
|
multi_json (1.3.7)
|
||||||
nokogiri (1.5.0)
|
multipart-post (1.1.5)
|
||||||
oauth2 (0.5.1)
|
nokogiri (1.5.5)
|
||||||
faraday (~> 0.7.4)
|
oauth2 (0.8.0)
|
||||||
multi_json (~> 1.0.3)
|
faraday (~> 0.8)
|
||||||
omniauth (1.0.1)
|
httpauth (~> 0.1)
|
||||||
|
jwt (~> 0.1.4)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rack (~> 1.2)
|
||||||
|
omniauth (1.0.3)
|
||||||
hashie (~> 1.2)
|
hashie (~> 1.2)
|
||||||
rack
|
rack
|
||||||
omniauth-facebook (1.0.0)
|
omniauth-facebook (1.4.0)
|
||||||
omniauth-oauth2 (~> 1.0.0)
|
omniauth-oauth2 (~> 1.0.2)
|
||||||
omniauth-oauth2 (1.0.0)
|
omniauth-oauth2 (1.0.3)
|
||||||
oauth2 (~> 0.5.0)
|
oauth2 (~> 0.8.0)
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
omniauth-openid (1.0.1)
|
omniauth-openid (1.0.1)
|
||||||
omniauth (~> 1.0)
|
omniauth (~> 1.0)
|
||||||
rack-openid (~> 1.3.1)
|
rack-openid (~> 1.3.1)
|
||||||
orm_adapter (0.3.0)
|
origin (1.0.10)
|
||||||
|
orm_adapter (0.4.0)
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
rack (1.4.1)
|
rack (1.4.1)
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
|
@ -94,19 +96,19 @@ GEM
|
||||||
ruby-openid (>= 2.1.8)
|
ruby-openid (>= 2.1.8)
|
||||||
rack-ssl (1.3.2)
|
rack-ssl (1.3.2)
|
||||||
rack
|
rack
|
||||||
rack-test (0.6.1)
|
rack-test (0.6.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.2.6)
|
rails (3.2.8)
|
||||||
actionmailer (= 3.2.6)
|
actionmailer (= 3.2.8)
|
||||||
actionpack (= 3.2.6)
|
actionpack (= 3.2.8)
|
||||||
activerecord (= 3.2.6)
|
activerecord (= 3.2.8)
|
||||||
activeresource (= 3.2.6)
|
activeresource (= 3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
railties (= 3.2.6)
|
railties (= 3.2.8)
|
||||||
railties (3.2.6)
|
railties (3.2.8)
|
||||||
actionpack (= 3.2.6)
|
actionpack (= 3.2.8)
|
||||||
activesupport (= 3.2.6)
|
activesupport (= 3.2.8)
|
||||||
rack-ssl (~> 1.3.2)
|
rack-ssl (~> 1.3.2)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
|
@ -114,18 +116,18 @@ GEM
|
||||||
rake (0.9.2.2)
|
rake (0.9.2.2)
|
||||||
rdoc (3.12)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.2.2)
|
||||||
sprockets (2.1.3)
|
sprockets (2.1.3)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
sqlite3 (1.3.5)
|
sqlite3 (1.3.6)
|
||||||
thor (0.15.2)
|
thor (0.16.0)
|
||||||
tilt (1.3.3)
|
tilt (1.3.3)
|
||||||
treetop (1.4.10)
|
treetop (1.4.12)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.33)
|
tzinfo (0.3.35)
|
||||||
warden (1.2.1)
|
warden (1.2.1)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
webrat (0.7.2)
|
webrat (0.7.2)
|
||||||
|
@ -139,12 +141,10 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activerecord-jdbc-adapter
|
activerecord-jdbc-adapter
|
||||||
activerecord-jdbcsqlite3-adapter
|
activerecord-jdbcsqlite3-adapter
|
||||||
bson_ext (~> 1.3.0)
|
|
||||||
devise!
|
devise!
|
||||||
jruby-openssl
|
jruby-openssl
|
||||||
mocha
|
mocha (= 0.10.0)
|
||||||
mongo (~> 1.3.0)
|
mongoid (~> 3.0)
|
||||||
mongoid (~> 2.0)
|
|
||||||
omniauth (~> 1.0.0)
|
omniauth (~> 1.0.0)
|
||||||
omniauth-facebook
|
omniauth-facebook
|
||||||
omniauth-oauth2 (~> 1.0.0)
|
omniauth-oauth2 (~> 1.0.0)
|
||||||
|
|
|
@ -456,7 +456,7 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
|
||||||
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
||||||
assert_match /<user>.*<\/user>/m, response.body
|
assert_match /<user>.*<\/user>/m, response.body
|
||||||
assert_match '<email></email>', response.body
|
assert_match '<email></email>', response.body
|
||||||
assert_match '<password nil="true"></password>', response.body
|
assert_match '<password nil="true"', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'sign in stub in json format' do
|
test 'sign in stub in json format' do
|
||||||
|
|
|
@ -21,7 +21,8 @@ class SerializableTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should not include unsafe keys on JSON' do
|
test 'should not include unsafe keys on JSON' do
|
||||||
assert_equal %w(created_at email facebook_token id updated_at username), from_json().keys.sort
|
keys = from_json().keys.select{ |key| !key.include?("id") }
|
||||||
|
assert_equal %w(created_at email facebook_token updated_at username), keys.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'should not include unsafe keys on JSON even if a new except is provided' do
|
test 'should not include unsafe keys on JSON even if a new except is provided' do
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
require 'mongoid/version'
|
require 'mongoid/version'
|
||||||
|
|
||||||
Mongoid.configure do |config|
|
Mongoid.configure do |config|
|
||||||
config.master = Mongo::Connection.new('127.0.0.1', 27017).db("devise-test-suite")
|
config.connect_to("devise-test-suite")
|
||||||
config.use_utc = true
|
config.use_utc = true
|
||||||
config.include_root_in_json = true
|
config.include_root_in_json = true
|
||||||
end
|
end
|
||||||
|
|
||||||
class ActiveSupport::TestCase
|
class ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
User.delete_all
|
Mongoid.purge!
|
||||||
Admin.delete_all
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ class Admin
|
||||||
include SharedAdmin
|
include SharedAdmin
|
||||||
|
|
||||||
## Database authenticatable
|
## Database authenticatable
|
||||||
field :email, :type => String, :null => true
|
field :email, :type => String
|
||||||
field :encrypted_password, :type => String, :null => true
|
field :encrypted_password, :type => String
|
||||||
|
|
||||||
## Recoverable
|
## Recoverable
|
||||||
field :reset_password_token, :type => String
|
field :reset_password_token, :type => String
|
||||||
|
@ -24,4 +24,6 @@ class Admin
|
||||||
|
|
||||||
## Lockable
|
## Lockable
|
||||||
field :locked_at, :type => Time
|
field :locked_at, :type => Time
|
||||||
|
|
||||||
|
field :active, :type => Boolean, :default => false
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,13 @@ module Shim
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def last(options={})
|
def last(options = {})
|
||||||
options.delete(:order) if options[:order] == "id"
|
options.delete(:order) if options[:order] == "id"
|
||||||
super(options)
|
where(options).last
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_by_email(email)
|
def find_by_email(email)
|
||||||
first(:conditions => { :email => email })
|
find_by(:email => email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ class User
|
||||||
field :facebook_token, :type => String
|
field :facebook_token, :type => String
|
||||||
|
|
||||||
## Database authenticatable
|
## Database authenticatable
|
||||||
field :email, :type => String, :null => false, :default => ""
|
field :email, :type => String, :default => ""
|
||||||
field :encrypted_password, :type => String, :null => false, :default => ""
|
field :encrypted_password, :type => String, :default => ""
|
||||||
|
|
||||||
## Recoverable
|
## Recoverable
|
||||||
field :reset_password_token, :type => String
|
field :reset_password_token, :type => String
|
||||||
|
|
Loading…
Reference in New Issue