pwnash-mongo_mapper 0.7.5 → 0.7.6

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.
Files changed (108) hide show
  1. data/lib/mongo_mapper.rb +6 -8
  2. data/lib/mongo_mapper/document.rb +6 -281
  3. data/lib/mongo_mapper/embedded_document.rb +5 -45
  4. data/lib/mongo_mapper/extensions.rb +190 -0
  5. data/lib/mongo_mapper/plugins.rb +27 -18
  6. data/lib/mongo_mapper/plugins/associations.rb +7 -6
  7. data/lib/mongo_mapper/plugins/associations/base.rb +1 -0
  8. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +1 -0
  9. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +1 -0
  10. data/lib/mongo_mapper/plugins/associations/collection.rb +1 -0
  11. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +1 -0
  12. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +2 -1
  13. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +1 -0
  14. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +4 -4
  15. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +1 -0
  16. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +1 -0
  17. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +1 -0
  18. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +1 -0
  19. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +1 -0
  20. data/lib/mongo_mapper/plugins/associations/proxy.rb +1 -0
  21. data/lib/mongo_mapper/plugins/callbacks.rb +4 -3
  22. data/lib/mongo_mapper/plugins/clone.rb +1 -0
  23. data/lib/mongo_mapper/plugins/descendants.rb +1 -0
  24. data/lib/mongo_mapper/plugins/dirty.rb +1 -0
  25. data/lib/mongo_mapper/plugins/document.rb +40 -0
  26. data/lib/mongo_mapper/plugins/dynamic_querying.rb +42 -0
  27. data/lib/mongo_mapper/{support/find.rb → plugins/dynamic_querying/dynamic_finder.rb} +2 -36
  28. data/lib/mongo_mapper/plugins/embedded_document.rb +48 -0
  29. data/lib/mongo_mapper/plugins/equality.rb +1 -0
  30. data/lib/mongo_mapper/plugins/identity_map.rb +8 -11
  31. data/lib/mongo_mapper/plugins/indexes.rb +11 -0
  32. data/lib/mongo_mapper/plugins/inspect.rb +1 -0
  33. data/lib/mongo_mapper/plugins/keys.rb +7 -9
  34. data/lib/mongo_mapper/plugins/keys/key.rb +12 -2
  35. data/lib/mongo_mapper/plugins/logger.rb +1 -0
  36. data/lib/mongo_mapper/plugins/modifiers.rb +3 -2
  37. data/lib/mongo_mapper/plugins/pagination.rb +1 -0
  38. data/lib/mongo_mapper/plugins/pagination/proxy.rb +1 -0
  39. data/lib/mongo_mapper/plugins/persistence.rb +1 -0
  40. data/lib/mongo_mapper/plugins/protected.rb +1 -0
  41. data/lib/mongo_mapper/plugins/query_logger.rb +5 -10
  42. data/lib/mongo_mapper/plugins/querying.rb +236 -0
  43. data/lib/mongo_mapper/plugins/rails.rb +1 -0
  44. data/lib/mongo_mapper/plugins/sci.rb +31 -0
  45. data/lib/mongo_mapper/plugins/serialization.rb +1 -0
  46. data/lib/mongo_mapper/plugins/timestamps.rb +1 -0
  47. data/lib/mongo_mapper/plugins/userstamps.rb +1 -0
  48. data/lib/mongo_mapper/plugins/validations.rb +5 -1
  49. data/lib/mongo_mapper/query.rb +53 -120
  50. data/lib/mongo_mapper/support.rb +2 -213
  51. data/lib/mongo_mapper/support/descendant_appends.rb +3 -6
  52. data/lib/mongo_mapper/version.rb +2 -1
  53. metadata +156 -190
  54. data/.gitignore +0 -10
  55. data/Rakefile +0 -37
  56. data/mongo_mapper.gemspec +0 -216
  57. data/performance/read_write.rb +0 -52
  58. data/specs.watchr +0 -51
  59. data/test/NOTE_ON_TESTING +0 -1
  60. data/test/active_model_lint_test.rb +0 -13
  61. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +0 -63
  62. data/test/functional/associations/test_belongs_to_proxy.rb +0 -101
  63. data/test/functional/associations/test_in_array_proxy.rb +0 -325
  64. data/test/functional/associations/test_many_documents_as_proxy.rb +0 -229
  65. data/test/functional/associations/test_many_documents_proxy.rb +0 -536
  66. data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +0 -176
  67. data/test/functional/associations/test_many_embedded_proxy.rb +0 -256
  68. data/test/functional/associations/test_many_polymorphic_proxy.rb +0 -302
  69. data/test/functional/associations/test_one_embedded_proxy.rb +0 -68
  70. data/test/functional/associations/test_one_proxy.rb +0 -196
  71. data/test/functional/test_associations.rb +0 -44
  72. data/test/functional/test_binary.rb +0 -27
  73. data/test/functional/test_callbacks.rb +0 -151
  74. data/test/functional/test_dirty.rb +0 -163
  75. data/test/functional/test_document.rb +0 -1219
  76. data/test/functional/test_embedded_document.rb +0 -210
  77. data/test/functional/test_identity_map.rb +0 -507
  78. data/test/functional/test_indexing.rb +0 -44
  79. data/test/functional/test_logger.rb +0 -20
  80. data/test/functional/test_modifiers.rb +0 -416
  81. data/test/functional/test_pagination.rb +0 -93
  82. data/test/functional/test_protected.rb +0 -163
  83. data/test/functional/test_string_id_compatibility.rb +0 -67
  84. data/test/functional/test_timestamps.rb +0 -64
  85. data/test/functional/test_userstamps.rb +0 -28
  86. data/test/functional/test_validations.rb +0 -342
  87. data/test/models.rb +0 -227
  88. data/test/support/custom_matchers.rb +0 -37
  89. data/test/support/timing.rb +0 -16
  90. data/test/test_helper.rb +0 -64
  91. data/test/unit/associations/test_base.rb +0 -212
  92. data/test/unit/associations/test_proxy.rb +0 -105
  93. data/test/unit/serializers/test_json_serializer.rb +0 -202
  94. data/test/unit/test_descendant_appends.rb +0 -71
  95. data/test/unit/test_document.rb +0 -225
  96. data/test/unit/test_dynamic_finder.rb +0 -123
  97. data/test/unit/test_embedded_document.rb +0 -657
  98. data/test/unit/test_keys.rb +0 -216
  99. data/test/unit/test_mongo_mapper.rb +0 -118
  100. data/test/unit/test_pagination.rb +0 -160
  101. data/test/unit/test_plugins.rb +0 -50
  102. data/test/unit/test_query.rb +0 -374
  103. data/test/unit/test_rails.rb +0 -181
  104. data/test/unit/test_rails_compatibility.rb +0 -52
  105. data/test/unit/test_serialization.rb +0 -51
  106. data/test/unit/test_support.rb +0 -390
  107. data/test/unit/test_time_zones.rb +0 -39
  108. data/test/unit/test_validations.rb +0 -544
data/Rakefile DELETED
@@ -1,37 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'jeweler'
4
-
5
- require File.dirname(__FILE__) + '/lib/mongo_mapper/version'
6
-
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "mongo_mapper"
9
- gem.summary = %Q{A Ruby Object Mapper for Mongo}
10
- gem.email = "nunemaker@gmail.com"
11
- gem.homepage = "http://github.com/jnunemaker/mongomapper"
12
- gem.authors = ["John Nunemaker"]
13
- gem.version = MongoMapper::Version
14
-
15
- gem.add_dependency('activesupport', '>= 2.3.4')
16
- gem.add_dependency('mongo', '1.0')
17
- gem.add_dependency('jnunemaker-validatable', '1.8.4')
18
-
19
- gem.add_development_dependency('json', '>= 1.2.3')
20
- gem.add_development_dependency('jnunemaker-matchy', '0.4.0')
21
- gem.add_development_dependency('shoulda', '2.10.2')
22
- gem.add_development_dependency('timecop', '0.3.1')
23
- gem.add_development_dependency('mocha', '0.9.8')
24
- end
25
-
26
- Jeweler::GemcutterTasks.new
27
-
28
- require 'rake/testtask'
29
- Rake::TestTask.new(:test) do |test|
30
- test.libs << 'test'
31
- test.ruby_opts << '-rubygems'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
-
36
- task :default => :test
37
- task :test => :check_dependencies
@@ -1,216 +0,0 @@
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{pwnash-mongo_mapper}
8
- s.version = "0.7.5"
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-05-16}
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
- "bin/mmconsole",
26
- "lib/mongo_mapper.rb",
27
- "lib/mongo_mapper/document.rb",
28
- "lib/mongo_mapper/embedded_document.rb",
29
- "lib/mongo_mapper/plugins.rb",
30
- "lib/mongo_mapper/plugins/associations.rb",
31
- "lib/mongo_mapper/plugins/associations/base.rb",
32
- "lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb",
33
- "lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb",
34
- "lib/mongo_mapper/plugins/associations/collection.rb",
35
- "lib/mongo_mapper/plugins/associations/embedded_collection.rb",
36
- "lib/mongo_mapper/plugins/associations/in_array_proxy.rb",
37
- "lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb",
38
- "lib/mongo_mapper/plugins/associations/many_documents_proxy.rb",
39
- "lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb",
40
- "lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb",
41
- "lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb",
42
- "lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb",
43
- "lib/mongo_mapper/plugins/associations/one_proxy.rb",
44
- "lib/mongo_mapper/plugins/associations/proxy.rb",
45
- "lib/mongo_mapper/plugins/callbacks.rb",
46
- "lib/mongo_mapper/plugins/clone.rb",
47
- "lib/mongo_mapper/plugins/descendants.rb",
48
- "lib/mongo_mapper/plugins/dirty.rb",
49
- "lib/mongo_mapper/plugins/equality.rb",
50
- "lib/mongo_mapper/plugins/identity_map.rb",
51
- "lib/mongo_mapper/plugins/inspect.rb",
52
- "lib/mongo_mapper/plugins/keys.rb",
53
- "lib/mongo_mapper/plugins/keys/key.rb",
54
- "lib/mongo_mapper/plugins/logger.rb",
55
- "lib/mongo_mapper/plugins/modifiers.rb",
56
- "lib/mongo_mapper/plugins/pagination.rb",
57
- "lib/mongo_mapper/plugins/pagination/proxy.rb",
58
- "lib/mongo_mapper/plugins/persistence.rb",
59
- "lib/mongo_mapper/plugins/protected.rb",
60
- "lib/mongo_mapper/plugins/query_logger.rb",
61
- "lib/mongo_mapper/plugins/rails.rb",
62
- "lib/mongo_mapper/plugins/serialization.rb",
63
- "lib/mongo_mapper/plugins/timestamps.rb",
64
- "lib/mongo_mapper/plugins/userstamps.rb",
65
- "lib/mongo_mapper/plugins/validations.rb",
66
- "lib/mongo_mapper/query.rb",
67
- "lib/mongo_mapper/support.rb",
68
- "lib/mongo_mapper/support/descendant_appends.rb",
69
- "lib/mongo_mapper/support/find.rb",
70
- "lib/mongo_mapper/version.rb",
71
- "mongo_mapper.gemspec",
72
- "performance/read_write.rb",
73
- "specs.watchr",
74
- "test/NOTE_ON_TESTING",
75
- "test/active_model_lint_test.rb",
76
- "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
77
- "test/functional/associations/test_belongs_to_proxy.rb",
78
- "test/functional/associations/test_in_array_proxy.rb",
79
- "test/functional/associations/test_many_documents_as_proxy.rb",
80
- "test/functional/associations/test_many_documents_proxy.rb",
81
- "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
82
- "test/functional/associations/test_many_embedded_proxy.rb",
83
- "test/functional/associations/test_many_polymorphic_proxy.rb",
84
- "test/functional/associations/test_one_embedded_proxy.rb",
85
- "test/functional/associations/test_one_proxy.rb",
86
- "test/functional/test_associations.rb",
87
- "test/functional/test_binary.rb",
88
- "test/functional/test_callbacks.rb",
89
- "test/functional/test_dirty.rb",
90
- "test/functional/test_document.rb",
91
- "test/functional/test_embedded_document.rb",
92
- "test/functional/test_identity_map.rb",
93
- "test/functional/test_indexing.rb",
94
- "test/functional/test_logger.rb",
95
- "test/functional/test_modifiers.rb",
96
- "test/functional/test_pagination.rb",
97
- "test/functional/test_protected.rb",
98
- "test/functional/test_string_id_compatibility.rb",
99
- "test/functional/test_timestamps.rb",
100
- "test/functional/test_userstamps.rb",
101
- "test/functional/test_validations.rb",
102
- "test/models.rb",
103
- "test/support/custom_matchers.rb",
104
- "test/support/timing.rb",
105
- "test/test_helper.rb",
106
- "test/unit/associations/test_base.rb",
107
- "test/unit/associations/test_proxy.rb",
108
- "test/unit/serializers/test_json_serializer.rb",
109
- "test/unit/test_descendant_appends.rb",
110
- "test/unit/test_document.rb",
111
- "test/unit/test_dynamic_finder.rb",
112
- "test/unit/test_embedded_document.rb",
113
- "test/unit/test_keys.rb",
114
- "test/unit/test_mongo_mapper.rb",
115
- "test/unit/test_pagination.rb",
116
- "test/unit/test_plugins.rb",
117
- "test/unit/test_query.rb",
118
- "test/unit/test_rails.rb",
119
- "test/unit/test_rails_compatibility.rb",
120
- "test/unit/test_serialization.rb",
121
- "test/unit/test_support.rb",
122
- "test/unit/test_time_zones.rb",
123
- "test/unit/test_validations.rb"
124
- ]
125
- s.homepage = %q{http://github.com/pwnash/mongomapper}
126
- s.rdoc_options = ["--charset=UTF-8"]
127
- s.require_paths = ["lib"]
128
- s.rubygems_version = %q{1.3.6}
129
- s.summary = %q{A Ruby Object Mapper for Mongo}
130
- s.test_files = [
131
- "test/active_model_lint_test.rb",
132
- "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
133
- "test/functional/associations/test_belongs_to_proxy.rb",
134
- "test/functional/associations/test_in_array_proxy.rb",
135
- "test/functional/associations/test_many_documents_as_proxy.rb",
136
- "test/functional/associations/test_many_documents_proxy.rb",
137
- "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
138
- "test/functional/associations/test_many_embedded_proxy.rb",
139
- "test/functional/associations/test_many_polymorphic_proxy.rb",
140
- "test/functional/associations/test_one_embedded_proxy.rb",
141
- "test/functional/associations/test_one_proxy.rb",
142
- "test/functional/test_associations.rb",
143
- "test/functional/test_binary.rb",
144
- "test/functional/test_callbacks.rb",
145
- "test/functional/test_dirty.rb",
146
- "test/functional/test_document.rb",
147
- "test/functional/test_embedded_document.rb",
148
- "test/functional/test_identity_map.rb",
149
- "test/functional/test_indexing.rb",
150
- "test/functional/test_logger.rb",
151
- "test/functional/test_modifiers.rb",
152
- "test/functional/test_pagination.rb",
153
- "test/functional/test_protected.rb",
154
- "test/functional/test_string_id_compatibility.rb",
155
- "test/functional/test_timestamps.rb",
156
- "test/functional/test_userstamps.rb",
157
- "test/functional/test_validations.rb",
158
- "test/models.rb",
159
- "test/support/custom_matchers.rb",
160
- "test/support/timing.rb",
161
- "test/test_helper.rb",
162
- "test/unit/associations/test_base.rb",
163
- "test/unit/associations/test_proxy.rb",
164
- "test/unit/serializers/test_json_serializer.rb",
165
- "test/unit/test_descendant_appends.rb",
166
- "test/unit/test_document.rb",
167
- "test/unit/test_dynamic_finder.rb",
168
- "test/unit/test_embedded_document.rb",
169
- "test/unit/test_keys.rb",
170
- "test/unit/test_mongo_mapper.rb",
171
- "test/unit/test_pagination.rb",
172
- "test/unit/test_plugins.rb",
173
- "test/unit/test_query.rb",
174
- "test/unit/test_rails.rb",
175
- "test/unit/test_rails_compatibility.rb",
176
- "test/unit/test_serialization.rb",
177
- "test/unit/test_support.rb",
178
- "test/unit/test_time_zones.rb",
179
- "test/unit/test_validations.rb"
180
- ]
181
-
182
- if s.respond_to? :specification_version then
183
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
184
- s.specification_version = 3
185
-
186
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
187
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
188
- s.add_runtime_dependency(%q<mongo>, ["= 1.0"])
189
- s.add_runtime_dependency(%q<jnunemaker-validatable>, ["= 1.8.4"])
190
- s.add_development_dependency(%q<json>, [">= 1.2.3"])
191
- s.add_development_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
192
- s.add_development_dependency(%q<shoulda>, ["= 2.10.2"])
193
- s.add_development_dependency(%q<timecop>, ["= 0.3.1"])
194
- s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
195
- else
196
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
197
- s.add_dependency(%q<mongo>, ["= 1.0"])
198
- s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.4"])
199
- s.add_dependency(%q<json>, [">= 1.2.3"])
200
- s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
201
- s.add_dependency(%q<shoulda>, ["= 2.10.2"])
202
- s.add_dependency(%q<timecop>, ["= 0.3.1"])
203
- s.add_dependency(%q<mocha>, ["= 0.9.8"])
204
- end
205
- else
206
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
207
- s.add_dependency(%q<mongo>, ["= 1.0"])
208
- s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.4"])
209
- s.add_dependency(%q<json>, [">= 1.2.3"])
210
- s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
211
- s.add_dependency(%q<shoulda>, ["= 2.10.2"])
212
- s.add_dependency(%q<timecop>, ["= 0.3.1"])
213
- s.add_dependency(%q<mocha>, ["= 0.9.8"])
214
- end
215
- end
216
-
@@ -1,52 +0,0 @@
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)
@@ -1,51 +0,0 @@
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
-
@@ -1 +0,0 @@
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.
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
- # For testing against edge rails also.
3
- # $:.unshift '/Users/jnunemaker/dev/ruby/rails/activemodel/lib'
4
- require 'active_model'
5
- require 'models'
6
-
7
- class ActiveModelLintTest < ActiveModel::TestCase
8
- include ActiveModel::Lint::Tests
9
-
10
- def setup
11
- @model = Post.new
12
- end
13
- end
@@ -1,63 +0,0 @@
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
@@ -1,101 +0,0 @@
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 = BSON::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