novelys_mongo_mapper 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +38 -0
  4. data/Rakefile +54 -0
  5. data/VERSION +1 -0
  6. data/bin/mmconsole +60 -0
  7. data/lib/mongo_mapper.rb +124 -0
  8. data/lib/mongo_mapper/descendant_appends.rb +44 -0
  9. data/lib/mongo_mapper/document.rb +423 -0
  10. data/lib/mongo_mapper/dynamic_finder.rb +74 -0
  11. data/lib/mongo_mapper/embedded_document.rb +67 -0
  12. data/lib/mongo_mapper/finder_options.rb +127 -0
  13. data/lib/mongo_mapper/plugins.rb +14 -0
  14. data/lib/mongo_mapper/plugins/associations.rb +104 -0
  15. data/lib/mongo_mapper/plugins/associations/base.rb +121 -0
  16. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +30 -0
  17. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +25 -0
  18. data/lib/mongo_mapper/plugins/associations/collection.rb +21 -0
  19. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +50 -0
  20. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +139 -0
  21. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +28 -0
  22. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +117 -0
  23. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +31 -0
  24. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +23 -0
  25. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +13 -0
  26. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +68 -0
  27. data/lib/mongo_mapper/plugins/associations/proxy.rb +118 -0
  28. data/lib/mongo_mapper/plugins/callbacks.rb +76 -0
  29. data/lib/mongo_mapper/plugins/clone.rb +13 -0
  30. data/lib/mongo_mapper/plugins/descendants.rb +16 -0
  31. data/lib/mongo_mapper/plugins/dirty.rb +119 -0
  32. data/lib/mongo_mapper/plugins/equality.rb +23 -0
  33. data/lib/mongo_mapper/plugins/identity_map.rb +122 -0
  34. data/lib/mongo_mapper/plugins/inspect.rb +14 -0
  35. data/lib/mongo_mapper/plugins/keys.rb +300 -0
  36. data/lib/mongo_mapper/plugins/logger.rb +17 -0
  37. data/lib/mongo_mapper/plugins/pagination.rb +85 -0
  38. data/lib/mongo_mapper/plugins/protected.rb +41 -0
  39. data/lib/mongo_mapper/plugins/rails.rb +45 -0
  40. data/lib/mongo_mapper/plugins/serialization.rb +105 -0
  41. data/lib/mongo_mapper/plugins/validations.rb +62 -0
  42. data/lib/mongo_mapper/support.rb +214 -0
  43. data/mongo_mapper.gemspec +179 -0
  44. data/performance/read_write.rb +52 -0
  45. data/specs.watchr +51 -0
  46. data/test/NOTE_ON_TESTING +1 -0
  47. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +63 -0
  48. data/test/functional/associations/test_belongs_to_proxy.rb +101 -0
  49. data/test/functional/associations/test_in_array_proxy.rb +309 -0
  50. data/test/functional/associations/test_many_documents_as_proxy.rb +229 -0
  51. data/test/functional/associations/test_many_documents_proxy.rb +431 -0
  52. data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +176 -0
  53. data/test/functional/associations/test_many_embedded_proxy.rb +256 -0
  54. data/test/functional/associations/test_many_polymorphic_proxy.rb +302 -0
  55. data/test/functional/associations/test_one_proxy.rb +161 -0
  56. data/test/functional/test_associations.rb +44 -0
  57. data/test/functional/test_binary.rb +27 -0
  58. data/test/functional/test_callbacks.rb +81 -0
  59. data/test/functional/test_dirty.rb +163 -0
  60. data/test/functional/test_document.rb +1245 -0
  61. data/test/functional/test_embedded_document.rb +125 -0
  62. data/test/functional/test_identity_map.rb +508 -0
  63. data/test/functional/test_logger.rb +20 -0
  64. data/test/functional/test_modifiers.rb +252 -0
  65. data/test/functional/test_pagination.rb +93 -0
  66. data/test/functional/test_protected.rb +139 -0
  67. data/test/functional/test_string_id_compatibility.rb +67 -0
  68. data/test/functional/test_validations.rb +329 -0
  69. data/test/models.rb +232 -0
  70. data/test/support/custom_matchers.rb +55 -0
  71. data/test/support/timing.rb +16 -0
  72. data/test/test_helper.rb +55 -0
  73. data/test/unit/associations/test_base.rb +207 -0
  74. data/test/unit/associations/test_proxy.rb +105 -0
  75. data/test/unit/serializers/test_json_serializer.rb +189 -0
  76. data/test/unit/test_descendant_appends.rb +71 -0
  77. data/test/unit/test_document.rb +231 -0
  78. data/test/unit/test_dynamic_finder.rb +125 -0
  79. data/test/unit/test_embedded_document.rb +663 -0
  80. data/test/unit/test_finder_options.rb +329 -0
  81. data/test/unit/test_keys.rb +169 -0
  82. data/test/unit/test_mongo_mapper.rb +65 -0
  83. data/test/unit/test_pagination.rb +127 -0
  84. data/test/unit/test_plugins.rb +50 -0
  85. data/test/unit/test_rails.rb +123 -0
  86. data/test/unit/test_rails_compatibility.rb +52 -0
  87. data/test/unit/test_serialization.rb +51 -0
  88. data/test/unit/test_support.rb +354 -0
  89. data/test/unit/test_time_zones.rb +39 -0
  90. data/test/unit/test_validations.rb +544 -0
  91. metadata +248 -0
@@ -0,0 +1,179 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{mongo_mapper}
8
+ s.version = "0.6.10"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["John Nunemaker"]
12
+ s.date = %q{2010-01-02}
13
+ s.default_executable = %q{mmconsole}
14
+ s.email = %q{nunemaker@gmail.com}
15
+ s.executables = ["mmconsole"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/mmconsole",
27
+ "lib/mongo_mapper.rb",
28
+ "lib/mongo_mapper/associations.rb",
29
+ "lib/mongo_mapper/associations/base.rb",
30
+ "lib/mongo_mapper/associations/belongs_to_polymorphic_proxy.rb",
31
+ "lib/mongo_mapper/associations/belongs_to_proxy.rb",
32
+ "lib/mongo_mapper/associations/collection.rb",
33
+ "lib/mongo_mapper/associations/in_array_proxy.rb",
34
+ "lib/mongo_mapper/associations/many_documents_as_proxy.rb",
35
+ "lib/mongo_mapper/associations/many_documents_proxy.rb",
36
+ "lib/mongo_mapper/associations/many_embedded_polymorphic_proxy.rb",
37
+ "lib/mongo_mapper/associations/many_embedded_proxy.rb",
38
+ "lib/mongo_mapper/associations/many_polymorphic_proxy.rb",
39
+ "lib/mongo_mapper/associations/one_proxy.rb",
40
+ "lib/mongo_mapper/associations/proxy.rb",
41
+ "lib/mongo_mapper/callbacks.rb",
42
+ "lib/mongo_mapper/dirty.rb",
43
+ "lib/mongo_mapper/document.rb",
44
+ "lib/mongo_mapper/dynamic_finder.rb",
45
+ "lib/mongo_mapper/embedded_document.rb",
46
+ "lib/mongo_mapper/finder_options.rb",
47
+ "lib/mongo_mapper/key.rb",
48
+ "lib/mongo_mapper/mongo_mapper.rb",
49
+ "lib/mongo_mapper/pagination.rb",
50
+ "lib/mongo_mapper/rails_compatibility/document.rb",
51
+ "lib/mongo_mapper/rails_compatibility/embedded_document.rb",
52
+ "lib/mongo_mapper/serialization.rb",
53
+ "lib/mongo_mapper/serializers/json_serializer.rb",
54
+ "lib/mongo_mapper/support.rb",
55
+ "lib/mongo_mapper/validations.rb",
56
+ "mongo_mapper.gemspec",
57
+ "specs.watchr",
58
+ "test/NOTE_ON_TESTING",
59
+ "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
60
+ "test/functional/associations/test_belongs_to_proxy.rb",
61
+ "test/functional/associations/test_in_array_proxy.rb",
62
+ "test/functional/associations/test_many_documents_as_proxy.rb",
63
+ "test/functional/associations/test_many_documents_proxy.rb",
64
+ "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
65
+ "test/functional/associations/test_many_embedded_proxy.rb",
66
+ "test/functional/associations/test_many_polymorphic_proxy.rb",
67
+ "test/functional/associations/test_one_proxy.rb",
68
+ "test/functional/test_associations.rb",
69
+ "test/functional/test_binary.rb",
70
+ "test/functional/test_callbacks.rb",
71
+ "test/functional/test_dirty.rb",
72
+ "test/functional/test_document.rb",
73
+ "test/functional/test_embedded_document.rb",
74
+ "test/functional/test_logger.rb",
75
+ "test/functional/test_modifiers.rb",
76
+ "test/functional/test_pagination.rb",
77
+ "test/functional/test_rails_compatibility.rb",
78
+ "test/functional/test_string_id_compatibility.rb",
79
+ "test/functional/test_validations.rb",
80
+ "test/models.rb",
81
+ "test/support/custom_matchers.rb",
82
+ "test/support/timing.rb",
83
+ "test/test_helper.rb",
84
+ "test/unit/associations/test_base.rb",
85
+ "test/unit/associations/test_proxy.rb",
86
+ "test/unit/serializers/test_json_serializer.rb",
87
+ "test/unit/test_document.rb",
88
+ "test/unit/test_dynamic_finder.rb",
89
+ "test/unit/test_embedded_document.rb",
90
+ "test/unit/test_finder_options.rb",
91
+ "test/unit/test_key.rb",
92
+ "test/unit/test_mongo_mapper.rb",
93
+ "test/unit/test_pagination.rb",
94
+ "test/unit/test_rails_compatibility.rb",
95
+ "test/unit/test_serializations.rb",
96
+ "test/unit/test_support.rb",
97
+ "test/unit/test_time_zones.rb",
98
+ "test/unit/test_validations.rb"
99
+ ]
100
+ s.homepage = %q{http://github.com/jnunemaker/mongomapper}
101
+ s.rdoc_options = ["--charset=UTF-8"]
102
+ s.require_paths = ["lib"]
103
+ s.rubygems_version = %q{1.3.5}
104
+ s.summary = %q{Awesome gem for modeling your domain and storing it in mongo}
105
+ s.test_files = [
106
+ "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
107
+ "test/functional/associations/test_belongs_to_proxy.rb",
108
+ "test/functional/associations/test_in_array_proxy.rb",
109
+ "test/functional/associations/test_many_documents_as_proxy.rb",
110
+ "test/functional/associations/test_many_documents_proxy.rb",
111
+ "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
112
+ "test/functional/associations/test_many_embedded_proxy.rb",
113
+ "test/functional/associations/test_many_polymorphic_proxy.rb",
114
+ "test/functional/associations/test_one_proxy.rb",
115
+ "test/functional/test_associations.rb",
116
+ "test/functional/test_binary.rb",
117
+ "test/functional/test_callbacks.rb",
118
+ "test/functional/test_dirty.rb",
119
+ "test/functional/test_document.rb",
120
+ "test/functional/test_embedded_document.rb",
121
+ "test/functional/test_logger.rb",
122
+ "test/functional/test_modifiers.rb",
123
+ "test/functional/test_pagination.rb",
124
+ "test/functional/test_rails_compatibility.rb",
125
+ "test/functional/test_string_id_compatibility.rb",
126
+ "test/functional/test_validations.rb",
127
+ "test/models.rb",
128
+ "test/support/custom_matchers.rb",
129
+ "test/support/timing.rb",
130
+ "test/test_helper.rb",
131
+ "test/unit/associations/test_base.rb",
132
+ "test/unit/associations/test_proxy.rb",
133
+ "test/unit/serializers/test_json_serializer.rb",
134
+ "test/unit/test_document.rb",
135
+ "test/unit/test_dynamic_finder.rb",
136
+ "test/unit/test_embedded_document.rb",
137
+ "test/unit/test_finder_options.rb",
138
+ "test/unit/test_key.rb",
139
+ "test/unit/test_mongo_mapper.rb",
140
+ "test/unit/test_pagination.rb",
141
+ "test/unit/test_rails_compatibility.rb",
142
+ "test/unit/test_serializations.rb",
143
+ "test/unit/test_support.rb",
144
+ "test/unit/test_time_zones.rb",
145
+ "test/unit/test_validations.rb"
146
+ ]
147
+
148
+ if s.respond_to? :specification_version then
149
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
150
+ s.specification_version = 3
151
+
152
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
153
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3"])
154
+ s.add_runtime_dependency(%q<mongo>, ["= 0.18.2"])
155
+ s.add_runtime_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
156
+ s.add_development_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
157
+ s.add_development_dependency(%q<shoulda>, ["= 2.10.2"])
158
+ s.add_development_dependency(%q<timecop>, ["= 0.3.1"])
159
+ s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
160
+ else
161
+ s.add_dependency(%q<activesupport>, [">= 2.3"])
162
+ s.add_dependency(%q<mongo>, ["= 0.18.2"])
163
+ s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
164
+ s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
165
+ s.add_dependency(%q<shoulda>, ["= 2.10.2"])
166
+ s.add_dependency(%q<timecop>, ["= 0.3.1"])
167
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
168
+ end
169
+ else
170
+ s.add_dependency(%q<activesupport>, [">= 2.3"])
171
+ s.add_dependency(%q<mongo>, ["= 0.18.2"])
172
+ s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
173
+ s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
174
+ s.add_dependency(%q<shoulda>, ["= 2.10.2"])
175
+ s.add_dependency(%q<timecop>, ["= 0.3.1"])
176
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
177
+ end
178
+ end
179
+
@@ -0,0 +1,52 @@
1
+ # The purpose of this is to check finding, initializing,
2
+ # and creating objects (typecasting times/dates and booleans).
3
+
4
+ require 'pp'
5
+ require 'benchmark'
6
+ require 'rubygems'
7
+
8
+ # to test with slow version just do this:
9
+ # gem 'mongo_mapper', '0.6.10'
10
+ # and comment out this:
11
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
12
+
13
+ require 'mongo_mapper'
14
+
15
+ MongoMapper.database = 'testing'
16
+
17
+ class Foo
18
+ include MongoMapper::Document
19
+ key :approved, Boolean
20
+ key :count, Integer
21
+ key :approved_at, Time
22
+ key :expire_on, Date
23
+ timestamps!
24
+ end
25
+ Foo.collection.remove
26
+
27
+ Benchmark.bm(5) do |x|
28
+ ids = []
29
+ x.report("write") do
30
+ 1000.times { |i| ids << Foo.create(:count => 0, :approved => true, :approved_at => Time.now, :expire_on => Date.today).id }
31
+ end
32
+
33
+ x.report("read ") do
34
+ ids.each { |id| Foo.first(:id => id) }
35
+ end
36
+ end
37
+
38
+ # I was get something like this on my puny macbook air:
39
+ # user system total real
40
+ # write 4.810000 0.090000 4.900000 ( 5.039949)
41
+ # read 2.730000 0.070000 2.800000 ( 2.990749)
42
+ #
43
+ #
44
+ # After these commits:
45
+ #
46
+ # * http://github.com/jnunemaker/mongomapper/commit/e5091fa140d5fae2721017b53027092233694ee5
47
+ # * http://github.com/jnunemaker/mongomapper/commit/c22bbde4fa1cfbc310d79cb0e50203310ffb03d1
48
+ #
49
+ # I'm now getting something like this:
50
+ # user system total real
51
+ # write 1.660000 0.050000 1.710000 ( 1.752676)
52
+ # read 1.060000 0.050000 1.110000 ( 1.263429)
data/specs.watchr ADDED
@@ -0,0 +1,51 @@
1
+ def growl(title, msg, img)
2
+ %x{growlnotify -m #{ msg.inspect} -t #{title.inspect} --image ~/.watchr/#{img}.png}
3
+ end
4
+
5
+ def form_growl_message(str)
6
+ results = str.split("\n").last
7
+ if results =~ /[1-9]\s(failure|error)s?/
8
+ growl "Test Results", "#{results}", "fail"
9
+ elsif results != ""
10
+ growl "Test Results", "#{results}", "pass"
11
+ end
12
+ end
13
+
14
+ def run(cmd)
15
+ puts(cmd)
16
+ output = ""
17
+ IO.popen(cmd) do |com|
18
+ com.each_char do |c|
19
+ print c
20
+ output << c
21
+ $stdout.flush
22
+ end
23
+ end
24
+ form_growl_message output
25
+ end
26
+
27
+ def run_test_file(file)
28
+ run %Q(ruby -I"lib:test" -rubygems #{file})
29
+ end
30
+
31
+ def run_all_tests
32
+ run "rake test"
33
+ end
34
+
35
+ def related_test_files(path)
36
+ Dir['test/**/*.rb'].select { |file| file =~ /test_#{File.basename(path)}/ }
37
+ end
38
+
39
+ watch('test/test_helper\.rb') { system('clear'); run_all_tests }
40
+ watch('test/.*/test_.*\.rb') { |m| system('clear'); run_test_file(m[0]) }
41
+ watch('lib/.*') { |m| related_test_files(m[0]).each { |file| run_test_file(file) } }
42
+
43
+ # Ctrl-\
44
+ Signal.trap('QUIT') do
45
+ puts " --- Running all tests ---\n\n"
46
+ run_all_tests
47
+ end
48
+
49
+ # Ctrl-C
50
+ Signal.trap('INT') { abort("\n") }
51
+
@@ -0,0 +1 @@
1
+ I am doing my best to keep unit and functional tests separate. As I see them, functional tests hit the database and should never care about internals. Unit tests do not hit the database.
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+ require 'models'
3
+
4
+ class BelongsToPolymorphicProxyTest < Test::Unit::TestCase
5
+ def setup
6
+ Status.collection.remove
7
+ Project.collection.remove
8
+ end
9
+
10
+ should "default to nil" do
11
+ status = Status.new
12
+ status.target.nil?.should be_true
13
+ status.target.inspect.should == "nil"
14
+ end
15
+
16
+ should "have boolean presence method" do
17
+ status = Status.new
18
+ status.target?.should be_false
19
+
20
+ status.target = Project.new(:name => 'mongomapper')
21
+ status.target?.should be_true
22
+ end
23
+
24
+ should "be able to replace the association" do
25
+ status = Status.new(:name => 'Foo!')
26
+ project = Project.new(:name => "mongomapper")
27
+ status.target = project
28
+ status.save.should be_true
29
+
30
+ status = status.reload
31
+ status.target.nil?.should be_false
32
+ status.target_id.should == project._id
33
+ status.target_type.should == "Project"
34
+ status.target.name.should == "mongomapper"
35
+ end
36
+
37
+ should "unset the association" do
38
+ status = Status.new(:name => 'Foo!')
39
+ project = Project.new(:name => "mongomapper")
40
+ status.target = project
41
+ status.save.should be_true
42
+
43
+ status = status.reload
44
+ status.target = nil
45
+ status.target_type.nil?.should be_true
46
+ status.target_id.nil?.should be_true
47
+ status.target.nil?.should be_true
48
+ end
49
+
50
+ context "association id set but document not found" do
51
+ setup do
52
+ @status = Status.new(:name => 'Foo!')
53
+ project = Project.new(:name => "mongomapper")
54
+ @status.target = project
55
+ @status.save.should be_true
56
+ project.destroy
57
+ end
58
+
59
+ should "return nil instead of raising error" do
60
+ @status.target.nil?.should be_true
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,101 @@
1
+ require 'test_helper'
2
+ require 'models'
3
+
4
+ class BelongsToProxyTest < Test::Unit::TestCase
5
+ def setup
6
+ @post_class = Doc()
7
+ @comment_class = Doc do
8
+ key :post_id, String
9
+ end
10
+
11
+ @comment_class.belongs_to :post, :class => @post_class
12
+ end
13
+
14
+ should "default to nil" do
15
+ @comment_class.new.post.nil?.should be_true
16
+ end
17
+
18
+ should "send object id to target" do
19
+ post = @post_class.new(:name => 'mongomapper')
20
+ comment = @comment_class.new(:name => 'Foo!', :post => post)
21
+ comment.save
22
+
23
+ comment.post.object_id.should == comment.post.target.object_id
24
+ end
25
+
26
+ should "have boolean presence method" do
27
+ comment = @comment_class.new(:name => 'Foo!')
28
+ comment.post?.should be_false
29
+
30
+ comment.post = @post_class.new(:name => 'mongomapper')
31
+ comment.post?.should be_true
32
+ end
33
+
34
+ should "be able to replace the association" do
35
+ post = @post_class.new(:name => 'mongomapper')
36
+ comment = @comment_class.new(:name => 'Foo!', :post => post)
37
+ comment.save.should be_true
38
+
39
+ comment = comment.reload
40
+ comment.post.should == post
41
+ comment.post.nil?.should be_false
42
+ end
43
+
44
+ should "unset the association" do
45
+ post = @post_class.new(:name => 'mongomapper')
46
+ comment = @comment_class.new(:name => 'Foo!', :post => post)
47
+ comment.save.should be_true
48
+
49
+ comment = comment.reload
50
+ comment.post = nil
51
+ comment.post.nil?.should be_true
52
+ end
53
+
54
+ should "return nil if id set but document not found" do
55
+ id = Mongo::ObjectID.new
56
+ @comment_class.new(:name => 'Foo', :post_id => id).post.nil?.should be_true
57
+ end
58
+
59
+ context ":dependent" do
60
+ setup do
61
+ # FIXME: make use of already defined models
62
+ class ::Property
63
+ include MongoMapper::Document
64
+ end
65
+ Property.collection.remove
66
+
67
+ class ::Thing
68
+ include MongoMapper::Document
69
+ key :name, String
70
+ end
71
+ Thing.collection.remove
72
+ end
73
+
74
+ teardown do
75
+ Object.send :remove_const, 'Property' if defined?(::Property)
76
+ Object.send :remove_const, 'Thing' if defined?(::Thing)
77
+ end
78
+
79
+ context "=> destroy" do
80
+ setup do
81
+ Property.key :thing_id, ObjectId
82
+ Property.belongs_to :thing, :dependent => :destroy
83
+ Thing.many :properties
84
+
85
+ @thing = Thing.create(:name => "Tree")
86
+ @property1 = Property.create
87
+ @property2 = Property.create
88
+ @property3 = Property.create
89
+ @thing.properties << @property1
90
+ @thing.properties << @property2
91
+ @thing.properties << @property3
92
+ end
93
+
94
+ should "not execute on a belongs_to association" do
95
+ Thing.count.should == 1
96
+ @property1.destroy
97
+ Thing.count.should == 1
98
+ end
99
+ end
100
+ end
101
+ end