mongodb 0.0.13 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -4
- data/lib/mongo/driver.rb +3 -3
- data/lib/mongo/driver/collection.rb +10 -22
- data/lib/mongo/driver/dynamic_finders.rb +1 -3
- data/lib/mongo/object.rb +2 -16
- data/lib/mongo/object/{object_helper.rb → collection_helper.rb} +12 -15
- data/lib/mongo/object/load.rb +22 -0
- data/lib/mongo/object/object.rb +60 -254
- data/lib/mongo/object/spec.rb +13 -3
- data/lib/mongo/object/spec/shared_object_crud.rb +124 -0
- data/lib/mongo/object/support.rb +15 -0
- data/lib/mongodb/gems.rb +1 -1
- data/spec/driver/collection_spec.rb +13 -43
- data/spec/driver/connection_spec.rb +1 -1
- data/spec/driver/database_spec.rb +1 -1
- data/spec/driver/dynamic_finders_spec.rb +4 -4
- data/spec/driver/fixes_spec.rb +2 -2
- data/spec/driver/hash_crud_spec.rb +69 -0
- data/spec/driver/spec_helper.rb +1 -3
- data/spec/migration/migration_spec.rb +4 -4
- data/spec/object/miscellaneous_spec.rb +23 -0
- data/spec/object/object_crud_spec.rb +57 -0
- data/spec/object/spec_helper.rb +1 -14
- metadata +11 -12
- data/lib/mongo/object/spec/crud_shared.rb +0 -63
- data/spec/driver/crud_spec.rb +0 -70
- data/spec/driver/hash_helper_spec.rb +0 -25
- data/spec/object/callbacks_spec.rb +0 -115
- data/spec/object/crud_spec.rb +0 -61
- data/spec/object/validation_spec.rb +0 -79
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'object/spec_helper'
|
2
|
-
|
3
|
-
describe 'Object validation' do
|
4
|
-
with_mongo
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
class Player
|
8
|
-
include Mongo::Object
|
9
|
-
|
10
|
-
attr_accessor :missions
|
11
|
-
|
12
|
-
class Mission
|
13
|
-
include Mongo::Object
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
after(:all){remove_constants :Player}
|
18
|
-
|
19
|
-
before do
|
20
|
-
@mission = Player::Mission.new
|
21
|
-
@player = Player.new
|
22
|
-
@player.missions = [@mission]
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should not save/update/destroy invalid objects' do
|
26
|
-
# create
|
27
|
-
@player.stub!(:valid?).and_return(false)
|
28
|
-
db.players.save(@player).should be_false
|
29
|
-
|
30
|
-
@player.stub!(:valid?).and_return(true)
|
31
|
-
db.players.save(@player).should be_true
|
32
|
-
|
33
|
-
# update
|
34
|
-
@player.stub!(:valid?).and_return(false)
|
35
|
-
db.players.save(@player).should be_false
|
36
|
-
|
37
|
-
@player.stub!(:valid?).and_return(true)
|
38
|
-
db.players.save(@player).should be_true
|
39
|
-
|
40
|
-
# destroy
|
41
|
-
@player.stub!(:valid?).and_return(false)
|
42
|
-
db.players.destroy(@player).should be_false
|
43
|
-
|
44
|
-
@player.stub!(:valid?).and_return(true)
|
45
|
-
db.players.destroy(@player).should be_true
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should not save/update/destroy invalid embedded objects' do
|
49
|
-
# create
|
50
|
-
@mission.stub!(:valid?).and_return(false)
|
51
|
-
db.players.save(@player).should be_false
|
52
|
-
|
53
|
-
@mission.stub!(:valid?).and_return(true)
|
54
|
-
db.players.save(@player).should be_true
|
55
|
-
|
56
|
-
# update
|
57
|
-
@mission.stub!(:valid?).and_return(false)
|
58
|
-
db.players.save(@player).should be_false
|
59
|
-
|
60
|
-
@mission.stub!(:valid?).and_return(true)
|
61
|
-
db.players.save(@player).should be_true
|
62
|
-
|
63
|
-
# destroy
|
64
|
-
@mission.stub!(:valid?).and_return(false)
|
65
|
-
db.players.destroy(@player).should be_false
|
66
|
-
|
67
|
-
@mission.stub!(:valid?).and_return(true)
|
68
|
-
db.players.destroy(@player).should be_true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should be able skip validation" do
|
72
|
-
@player.stub!(:valid?).and_return(false)
|
73
|
-
db.players.save(@player, validate: false).should be_true
|
74
|
-
|
75
|
-
@player.stub!(:valid?).and_return(true)
|
76
|
-
@mission.stub!(:valid?).and_return(false)
|
77
|
-
db.players.save(@player, validate: false).should be_true
|
78
|
-
end
|
79
|
-
end
|