Merge pull request #2139 from durran/mongoid-3-test-fixes

Fix spec failures for Mongoid 3.
This commit is contained in:
José Valim
2012-11-10 11:49:05 -08:00
8 changed files with 78 additions and 78 deletions

View File

@@ -11,7 +11,7 @@ group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.2", :require => false
gem "mocha", :require => false
gem "mocha", "0.10.0", :require => false
end
platforms :jruby do
@@ -24,8 +24,6 @@ platforms :ruby do
gem "sqlite3"
group :mongoid do
gem "mongo", "~> 1.3.0"
gem "mongoid", "~> 2.0"
gem "bson_ext", "~> 1.3.0"
gem "mongoid", "~> 3.0"
end
end

View File

@@ -10,81 +10,83 @@ PATH
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.6)
actionpack (= 3.2.6)
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activesupport (3.2.6)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.6)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bson (1.5.1)
bson_ext (1.3.1)
builder (3.0.0)
builder (3.0.4)
erubis (2.7.0)
faraday (0.7.5)
addressable (~> 2.2.6)
multipart-post (~> 1.1.3)
rack (>= 1.1.0, < 2)
faraday (0.8.4)
multipart-post (~> 1.1)
hashie (1.2.0)
hike (1.2.1)
i18n (0.6.0)
httpauth (0.2.0)
i18n (0.6.1)
journey (1.0.4)
json (1.7.3)
json (1.7.5)
jwt (0.1.5)
multi_json (>= 1.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.18)
mime-types (1.19)
mocha (0.10.0)
metaclass (~> 0.0.1)
mongo (1.3.1)
bson (>= 1.3.1)
mongoid (2.3.4)
mongoid (3.0.11)
activemodel (~> 3.1)
mongo (~> 1.3)
moped (~> 1.1)
origin (~> 1.0)
tzinfo (~> 0.3.22)
multi_json (1.0.4)
multipart-post (1.1.4)
nokogiri (1.5.0)
oauth2 (0.5.1)
faraday (~> 0.7.4)
multi_json (~> 1.0.3)
omniauth (1.0.1)
moped (1.2.8)
multi_json (1.3.7)
multipart-post (1.1.5)
nokogiri (1.5.5)
oauth2 (0.8.0)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
omniauth (1.0.3)
hashie (~> 1.2)
rack
omniauth-facebook (1.0.0)
omniauth-oauth2 (~> 1.0.0)
omniauth-oauth2 (1.0.0)
oauth2 (~> 0.5.0)
omniauth-facebook (1.4.0)
omniauth-oauth2 (~> 1.0.2)
omniauth-oauth2 (1.0.3)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.3.0)
origin (1.0.10)
orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -94,19 +96,19 @@ GEM
ruby-openid (>= 2.1.8)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.6)
actionmailer (= 3.2.6)
actionpack (= 3.2.6)
activerecord (= 3.2.6)
activeresource (= 3.2.6)
activesupport (= 3.2.6)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.6)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -114,18 +116,18 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
ruby-openid (2.1.8)
ruby-openid (2.2.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.15.2)
sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
tzinfo (0.3.35)
warden (1.2.1)
rack (>= 1.0)
webrat (0.7.2)
@@ -139,12 +141,10 @@ PLATFORMS
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
bson_ext (~> 1.3.0)
devise!
jruby-openssl
mocha
mongo (~> 1.3.0)
mongoid (~> 2.0)
mocha (= 0.10.0)
mongoid (~> 3.0)
omniauth (~> 1.0.0)
omniauth-facebook
omniauth-oauth2 (~> 1.0.0)

View File

@@ -456,7 +456,7 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
assert_match /<user>.*<\/user>/m, response.body
assert_match '<email></email>', response.body
assert_match '<password nil="true"></password>', response.body
assert_match '<password nil="true"', response.body
end
test 'sign in stub in json format' do

View File

@@ -21,7 +21,8 @@ class SerializableTest < ActiveSupport::TestCase
end
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
test 'should not include unsafe keys on JSON even if a new except is provided' do

View File

@@ -1,14 +1,13 @@
require 'mongoid/version'
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.include_root_in_json = true
end
class ActiveSupport::TestCase
setup do
User.delete_all
Admin.delete_all
Mongoid.purge!
end
end

View File

@@ -6,8 +6,8 @@ class Admin
include SharedAdmin
## Database authenticatable
field :email, :type => String, :null => true
field :encrypted_password, :type => String, :null => true
field :email, :type => String
field :encrypted_password, :type => String
## Recoverable
field :reset_password_token, :type => String
@@ -24,4 +24,6 @@ class Admin
## Lockable
field :locked_at, :type => Time
field :active, :type => Boolean, :default => false
end

View File

@@ -7,13 +7,13 @@ module Shim
end
module ClassMethods
def last(options={})
def last(options = {})
options.delete(:order) if options[:order] == "id"
super(options)
where(options).last
end
def find_by_email(email)
first(:conditions => { :email => email })
find_by(:email => email)
end
end

View File

@@ -9,8 +9,8 @@ class User
field :facebook_token, :type => String
## Database authenticatable
field :email, :type => String, :null => false, :default => ""
field :encrypted_password, :type => String, :null => false, :default => ""
field :email, :type => String, :default => ""
field :encrypted_password, :type => String, :default => ""
## Recoverable
field :reset_password_token, :type => String