mongoid-pre 2.0.0.beta1 → 2.0.0.pre

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 (135) hide show
  1. data/.watchr +15 -10
  2. data/HISTORY +342 -0
  3. data/README.rdoc +8 -1
  4. data/Rakefile +2 -3
  5. data/VERSION +1 -1
  6. data/lib/mongoid/associations/{embedded_in.rb → belongs_to.rb} +4 -4
  7. data/lib/mongoid/associations/belongs_to_related.rb +9 -6
  8. data/lib/mongoid/associations/{embeds_many.rb → has_many.rb} +20 -33
  9. data/lib/mongoid/associations/has_many_related.rb +4 -28
  10. data/lib/mongoid/associations/{embeds_one.rb → has_one.rb} +6 -6
  11. data/lib/mongoid/associations/options.rb +6 -1
  12. data/lib/mongoid/associations.rb +32 -41
  13. data/lib/mongoid/attributes.rb +6 -13
  14. data/lib/mongoid/collection.rb +1 -2
  15. data/lib/mongoid/commands/delete.rb +1 -1
  16. data/lib/mongoid/commands/delete_all.rb +1 -4
  17. data/lib/mongoid/commands/destroy.rb +1 -1
  18. data/lib/mongoid/commands/destroy_all.rb +1 -3
  19. data/lib/mongoid/commands/save.rb +0 -1
  20. data/lib/mongoid/commands.rb +13 -2
  21. data/lib/mongoid/components.rb +1 -6
  22. data/lib/mongoid/config.rb +1 -5
  23. data/lib/mongoid/contexts/enumerable.rb +17 -54
  24. data/lib/mongoid/contexts/mongo.rb +38 -101
  25. data/lib/mongoid/contexts/paging.rb +2 -2
  26. data/lib/mongoid/contexts.rb +0 -21
  27. data/lib/mongoid/criteria.rb +73 -15
  28. data/lib/mongoid/criterion/inclusion.rb +0 -2
  29. data/lib/mongoid/criterion/optional.rb +2 -10
  30. data/lib/mongoid/document.rb +30 -41
  31. data/lib/mongoid/extensions.rb +0 -15
  32. data/lib/mongoid/field.rb +7 -20
  33. data/lib/mongoid/fields.rb +10 -15
  34. data/lib/mongoid/finders.rb +98 -10
  35. data/lib/mongoid/identity.rb +2 -8
  36. data/lib/mongoid/named_scope.rb +0 -2
  37. data/lib/mongoid/validations/associated.rb +8 -3
  38. data/lib/mongoid/validations/uniqueness.rb +7 -2
  39. data/lib/mongoid/validations.rb +2 -2
  40. data/lib/mongoid/versioning.rb +1 -1
  41. data/lib/mongoid.rb +5 -21
  42. data/mongoid.gemspec +19 -59
  43. data/spec/integration/mongoid/associations_spec.rb +3 -42
  44. data/spec/integration/mongoid/attributes_spec.rb +2 -2
  45. data/spec/integration/mongoid/commands_spec.rb +13 -27
  46. data/spec/integration/mongoid/contexts/enumerable_spec.rb +0 -13
  47. data/spec/integration/mongoid/criteria_spec.rb +3 -50
  48. data/spec/integration/mongoid/document_spec.rb +5 -72
  49. data/spec/integration/mongoid/finders_spec.rb +28 -85
  50. data/spec/models/address.rb +3 -3
  51. data/spec/models/animal.rb +2 -2
  52. data/spec/models/country_code.rb +2 -2
  53. data/spec/models/game.rb +1 -2
  54. data/spec/models/inheritance.rb +5 -5
  55. data/spec/models/location.rb +2 -2
  56. data/spec/models/name.rb +3 -3
  57. data/spec/models/namespacing.rb +2 -2
  58. data/spec/models/patient.rb +0 -2
  59. data/spec/models/person.rb +4 -6
  60. data/spec/models/pet.rb +3 -3
  61. data/spec/models/pet_owner.rb +3 -3
  62. data/spec/models/phone.rb +3 -3
  63. data/spec/models/post.rb +1 -1
  64. data/spec/models/translation.rb +2 -2
  65. data/spec/models/vet_visit.rb +2 -2
  66. data/spec/spec_helper.rb +2 -2
  67. data/spec/unit/mongoid/associations/belongs_to_related_spec.rb +0 -4
  68. data/spec/unit/mongoid/associations/{embedded_in_spec.rb → belongs_to_spec.rb} +11 -11
  69. data/spec/unit/mongoid/associations/has_many_related_spec.rb +14 -45
  70. data/spec/unit/mongoid/associations/{embeds_many_spec.rb → has_many_spec.rb} +34 -79
  71. data/spec/unit/mongoid/associations/{embeds_one_spec.rb → has_one_spec.rb} +18 -18
  72. data/spec/unit/mongoid/associations/options_spec.rb +19 -20
  73. data/spec/unit/mongoid/associations_spec.rb +12 -74
  74. data/spec/unit/mongoid/attributes_spec.rb +51 -83
  75. data/spec/unit/mongoid/collection_spec.rb +0 -46
  76. data/spec/unit/mongoid/commands/delete_all_spec.rb +8 -9
  77. data/spec/unit/mongoid/commands/delete_spec.rb +3 -6
  78. data/spec/unit/mongoid/commands/destroy_all_spec.rb +2 -0
  79. data/spec/unit/mongoid/commands/destroy_spec.rb +3 -10
  80. data/spec/unit/mongoid/commands_spec.rb +11 -20
  81. data/spec/unit/mongoid/config_spec.rb +0 -18
  82. data/spec/unit/mongoid/contexts/enumerable_spec.rb +11 -198
  83. data/spec/unit/mongoid/contexts/mongo_spec.rb +54 -357
  84. data/spec/unit/mongoid/criteria_spec.rb +78 -107
  85. data/spec/unit/mongoid/criterion/exclusion_spec.rb +13 -3
  86. data/spec/unit/mongoid/criterion/inclusion_spec.rb +19 -25
  87. data/spec/unit/mongoid/criterion/optional_spec.rb +18 -25
  88. data/spec/unit/mongoid/document_spec.rb +34 -71
  89. data/spec/unit/mongoid/extensions/array/conversions_spec.rb +2 -2
  90. data/spec/unit/mongoid/extensions/datetime/conversions_spec.rb +3 -0
  91. data/spec/unit/mongoid/extensions/object/conversions_spec.rb +2 -16
  92. data/spec/unit/mongoid/extensions/proc/scoping_spec.rb +1 -1
  93. data/spec/unit/mongoid/field_spec.rb +0 -62
  94. data/spec/unit/mongoid/fields_spec.rb +0 -33
  95. data/spec/unit/mongoid/finders_spec.rb +1 -37
  96. data/spec/unit/mongoid/identity_spec.rb +6 -47
  97. data/spec/unit/mongoid/named_scope_spec.rb +2 -15
  98. data/spec/unit/mongoid/scope_spec.rb +1 -1
  99. data/spec/unit/mongoid/validations/uniqueness_spec.rb +3 -3
  100. data/spec/unit/mongoid_spec.rb +2 -11
  101. metadata +14 -64
  102. data/lib/mongoid/associations/meta_data.rb +0 -28
  103. data/lib/mongoid/contexts/ids.rb +0 -25
  104. data/lib/mongoid/deprecation.rb +0 -22
  105. data/lib/mongoid/dirty.rb +0 -203
  106. data/lib/mongoid/extensions/big_decimal/conversions.rb +0 -19
  107. data/lib/mongoid/extensions/binary/conversions.rb +0 -17
  108. data/lib/mongoid/extensions/objectid/conversions.rb +0 -15
  109. data/lib/mongoid/extras.rb +0 -61
  110. data/lib/mongoid/javascript/functions.yml +0 -37
  111. data/lib/mongoid/javascript.rb +0 -21
  112. data/lib/mongoid/observable.rb +0 -30
  113. data/lib/mongoid/paths.rb +0 -54
  114. data/lib/mongoid/persistence/command.rb +0 -20
  115. data/lib/mongoid/persistence/insert.rb +0 -71
  116. data/lib/mongoid/persistence/update.rb +0 -78
  117. data/lib/mongoid/persistence.rb +0 -27
  118. data/lib/mongoid/state.rb +0 -32
  119. data/spec/integration/mongoid/dirty_spec.rb +0 -70
  120. data/spec/integration/mongoid/persistence/update_spec.rb +0 -46
  121. data/spec/models/callbacks.rb +0 -18
  122. data/spec/unit/mongoid/associations/meta_data_spec.rb +0 -88
  123. data/spec/unit/mongoid/contexts_spec.rb +0 -25
  124. data/spec/unit/mongoid/deprecation_spec.rb +0 -24
  125. data/spec/unit/mongoid/dirty_spec.rb +0 -286
  126. data/spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb +0 -22
  127. data/spec/unit/mongoid/extensions/binary/conversions_spec.rb +0 -22
  128. data/spec/unit/mongoid/extras_spec.rb +0 -102
  129. data/spec/unit/mongoid/javascript_spec.rb +0 -48
  130. data/spec/unit/mongoid/observable_spec.rb +0 -46
  131. data/spec/unit/mongoid/paths_spec.rb +0 -124
  132. data/spec/unit/mongoid/persistence/insert_spec.rb +0 -175
  133. data/spec/unit/mongoid/persistence/update_spec.rb +0 -148
  134. data/spec/unit/mongoid/persistence_spec.rb +0 -40
  135. data/spec/unit/mongoid/state_spec.rb +0 -83
@@ -121,12 +121,6 @@ describe Mongoid::Document do
121
121
  lambda { Person.find(@person.id) }.should raise_error
122
122
  end
123
123
 
124
- it "marks the document as destroyed" do
125
- @person.should_not be_destroyed
126
- @person.destroy
127
- @person.should be_destroyed
128
- end
129
-
130
124
  end
131
125
 
132
126
  context "on an embedded document" do
@@ -250,7 +244,7 @@ describe Mongoid::Document do
250
244
 
251
245
  before do
252
246
  5.times do |num|
253
- Person.create(:title => "Sir", :age => num, :ssn => num)
247
+ Person.create(:title => "Sir", :age => num)
254
248
  end
255
249
  end
256
250
 
@@ -291,7 +285,7 @@ describe Mongoid::Document do
291
285
  end
292
286
 
293
287
  it "returns a pretty string of class name and attributes" do
294
- attrs = Person.fields.map { |name, field| "#{name}: #{@person.attributes[name].nil? ? 'nil' : @person.attributes[name]}" } * ", "
288
+ attrs = Person.fields.map { |name, field| "#{name}: #{@person.attributes[name] || 'nil'}" } * ", "
295
289
  @person.inspect.should == "#<Person _id: #{@person.id}, #{attrs}>"
296
290
  end
297
291
 
@@ -331,10 +325,6 @@ describe Mongoid::Document do
331
325
  @person.age.should == 35
332
326
  end
333
327
 
334
- it "reload should return self" do
335
- @person.reload.should == @from_db
336
- end
337
-
338
328
  end
339
329
 
340
330
  describe "#save" do
@@ -427,7 +417,7 @@ describe Mongoid::Document do
427
417
  @person.addresses << @business
428
418
  end
429
419
 
430
- it "allows adding multiples on an embeds_many in a row" do
420
+ it "allows adding multiples on a has_many in a row" do
431
421
  @person.addresses.length.should == 2
432
422
  end
433
423
 
@@ -444,13 +434,13 @@ describe Mongoid::Document do
444
434
 
445
435
  end
446
436
 
447
- context "when saving on an embeds_many" do
437
+ context "when saving on a has_many" do
448
438
 
449
439
  before do
450
440
  @home.save
451
441
  end
452
442
 
453
- it "saves the entire graph up from the embeds_many" do
443
+ it "saves the entire graph up from the has_many" do
454
444
  person = Person.first(:conditions => { :title => "Sir" })
455
445
  person.should == @person
456
446
  end
@@ -501,63 +491,6 @@ describe Mongoid::Document do
501
491
  end
502
492
 
503
493
  end
504
-
505
- describe "#as_json" do
506
-
507
- before do
508
- @person = Person.new(:title => "Sir", :age => 30)
509
- @address = Address.new(:street => "Nan Jing Dong Lu")
510
- @person.addresses << @address
511
- end
512
-
513
- context "on a new document" do
514
-
515
- it "returns the attributes" do
516
- @person.as_json.should == @person.attributes
517
- end
518
-
519
- end
520
-
521
- context "on a persisted document" do
522
-
523
- it "returns the attributes" do
524
- @person.save
525
- from_db = Person.find(@person.id)
526
- from_db.as_json.should == from_db.attributes
527
- end
528
-
529
- end
530
-
531
- end
532
-
533
- describe "#encode_json" do
534
-
535
- before do
536
- @person = Person.new(:title => "Sir", :age => 30)
537
- @address = Address.new(:street => "Nan Jing Dong Lu")
538
- @person.addresses << @address
539
- @encoder = Array.new
540
- end
541
-
542
- context "on a new document" do
543
-
544
- it "returns the attributes" do
545
- @person.encode_json(@encoder).should == @person.attributes
546
- end
547
-
548
- end
549
-
550
- context "on a persisted document" do
551
-
552
- it "returns the attributes" do
553
- @person.save
554
- from_db = Person.find(@person.id)
555
- from_db.encode_json(@encoder).should == from_db.attributes
556
- end
557
-
558
- end
559
-
560
- end
561
494
 
562
495
  context "typecasting" do
563
496
 
@@ -4,116 +4,59 @@ describe Mongoid::Finders do
4
4
 
5
5
  describe "#find" do
6
6
 
7
- context "using string ids" do
8
-
9
- before do
10
- @documents = []
11
- @document = Person.create(:title => "Mrs.", :ssn => "another")
12
- 3.times do |n|
13
- @documents << Person.create(:title => "Mr.", :ssn => "#{n}22")
14
- end
7
+ before do
8
+ @documents = []
9
+ @document = Person.create(:title => "Mrs.", :ssn => "another")
10
+ 3.times do |n|
11
+ @documents << Person.create(:title => "Mr.", :ssn => "#{n}22")
15
12
  end
13
+ end
16
14
 
17
- after do
18
- Person.delete_all
19
- end
20
-
21
- context "with an id as an argument" do
22
-
23
- context "when the document is found" do
24
-
25
- it "returns the document" do
26
- Person.find(@document.id).should == @document
27
- end
28
-
29
- end
15
+ after do
16
+ Person.delete_all
17
+ end
30
18
 
31
- context "when the document is not found" do
19
+ context "with an id as an argument" do
32
20
 
33
- it "raises an error" do
34
- lambda { Person.find("5") }.should raise_error
35
- end
21
+ context "when the document is found" do
36
22
 
23
+ it "returns the document" do
24
+ Person.find(@document.id).should == @document
37
25
  end
38
26
 
39
27
  end
40
28
 
41
- context "with an array of ids as args" do
42
-
43
- context "when the documents are found" do
44
-
45
- it "returns an array of the documents" do
46
- @people = Person.find(@documents.map(&:id))
47
- @people.should == @documents
48
- end
29
+ context "when the document is not found" do
49
30
 
31
+ it "raises an error" do
32
+ lambda { Person.find("5") }.should raise_error
50
33
  end
51
34
 
52
- context "when no documents found" do
53
-
54
- it "raises an error" do
55
- lambda { Person.find(["11", "21", "31"]) }.should raise_error
56
- end
57
-
58
- end
59
35
  end
60
- end
61
36
 
62
- context "using object ids" do
63
-
64
- before do
65
- Mongoid.use_object_ids = true
66
- @documents = []
67
- @document = Person.create(:title => "Mrs.", :ssn => "another")
68
- 3.times do |n|
69
- @documents << Person.create(:title => "Mr.", :ssn => "#{n}22")
70
- end
71
- end
72
-
73
- after do
74
- Mongoid.use_object_ids = false
75
- Person.delete_all
76
- end
77
-
78
- context "with an id as an argument" do
79
-
80
- context "when the document is found" do
81
-
82
- it "returns the document" do
83
- Person.find(@document.id).should == @document
84
- end
85
-
86
- end
37
+ end
87
38
 
88
- context "when the document is not found" do
39
+ context "with an array of ids as args" do
89
40
 
90
- it "raises an error" do
91
- lambda { Person.find("5") }.should raise_error
92
- end
41
+ context "when the documents are found" do
93
42
 
43
+ it "returns an array of the documents" do
44
+ @people = Person.find(@documents.map(&:id))
45
+ @people.should == @documents
94
46
  end
95
47
 
96
48
  end
97
49
 
98
- context "with an array of ids as args" do
99
-
100
- context "when the documents are found" do
101
-
102
- it "returns an array of the documents" do
103
- @people = Person.find(@documents.map(&:id))
104
- @people.should == @documents
105
- end
50
+ context "when no documents found" do
106
51
 
52
+ it "raises an error" do
53
+ lambda { Person.find(["11", "21", "31"]) }.should raise_error
107
54
  end
108
55
 
109
- context "when no documents found" do
110
-
111
- it "raises an error" do
112
- lambda { Person.find(["11", "21", "31"]) }.should raise_error
113
- end
114
-
115
- end
116
56
  end
57
+
117
58
  end
59
+
118
60
  end
61
+
119
62
  end
@@ -9,9 +9,9 @@ class Address
9
9
  field :parent_title
10
10
  field :services, :type => Array
11
11
  key :street
12
- embeds_many :locations
12
+ has_many :locations
13
13
 
14
- embedded_in :addressable, :inverse_of => :addresses do
14
+ belongs_to :addressable, :inverse_of => :addresses do
15
15
  def extension
16
16
  "Testing"
17
17
  end
@@ -36,4 +36,4 @@ class Address
36
36
  end
37
37
 
38
38
  end
39
- end
39
+ end
@@ -2,5 +2,5 @@ class Animal
2
2
  include Mongoid::Document
3
3
  field :name
4
4
  key :name
5
- embedded_in :person, :inverse_of => :pet
6
- end
5
+ belongs_to :person, :inverse_of => :pet
6
+ end
@@ -2,5 +2,5 @@ class CountryCode
2
2
  include Mongoid::Document
3
3
  field :code, :type => Integer
4
4
  key :code
5
- embedded_in :phone_number, :inverse_of => :country_codes
6
- end
5
+ belongs_to :phone_number, :inverse_of => :country_codes
6
+ end
data/spec/models/game.rb CHANGED
@@ -3,5 +3,4 @@ class Game
3
3
  field :high_score, :default => 500
4
4
  field :score, :type => Integer, :default => 0
5
5
  belongs_to_related :person
6
- enslave and cache
7
- end
6
+ end
@@ -1,8 +1,8 @@
1
1
  class Canvas
2
2
  include Mongoid::Document
3
3
  field :name
4
- embeds_many :shapes
5
- embeds_one :writer
4
+ has_many :shapes
5
+ has_one :writer
6
6
 
7
7
  def render
8
8
  shapes.each { |shape| render }
@@ -24,7 +24,7 @@ class Shape
24
24
  field :x, :type => Integer, :default => 0
25
25
  field :y, :type => Integer, :default => 0
26
26
 
27
- embedded_in :canvas, :inverse_of => :shapes
27
+ belongs_to :canvas, :inverse_of => :shapes
28
28
 
29
29
  def render; end
30
30
  end
@@ -42,7 +42,7 @@ class Writer
42
42
  include Mongoid::Document
43
43
  field :speed, :type => Integer, :default => 0
44
44
 
45
- embedded_in :canvas, :inverse_of => :writer
45
+ belongs_to :canvas, :inverse_of => :writer
46
46
 
47
47
  def write; end
48
48
  end
@@ -53,4 +53,4 @@ end
53
53
 
54
54
  class PdfWriter < Writer
55
55
  def write; end
56
- end
56
+ end
@@ -1,5 +1,5 @@
1
1
  class Location
2
2
  include Mongoid::Document
3
3
  field :name
4
- embedded_in :address, :inverse_of => :locations
5
- end
4
+ belongs_to :address, :inverse_of => :locations
5
+ end
data/spec/models/name.rb CHANGED
@@ -4,10 +4,10 @@ class Name
4
4
  field :last_name
5
5
  field :parent_title
6
6
  key :first_name, :last_name
7
- embeds_many :translations
8
- embedded_in :person, :inverse_of => :name
7
+ has_many :translations
8
+ belongs_to :person, :inverse_of => :name
9
9
 
10
10
  def set_parent=(set = false)
11
11
  self.parent_title = person.title if set
12
12
  end
13
- end
13
+ end
@@ -2,10 +2,10 @@ module Medical
2
2
  class Patient
3
3
  include Mongoid::Document
4
4
  field :name
5
- embeds_many :prescriptions, :class_name => "Medical::Prescription"
5
+ has_many :prescriptions, :class_name => "Medical::Prescription"
6
6
  end
7
7
  class Prescription
8
8
  include Mongoid::Document
9
9
  field :name
10
10
  end
11
- end
11
+ end
@@ -1,6 +1,4 @@
1
1
  class Patient
2
2
  include Mongoid::Document
3
- field :title
4
3
  store_in :inpatient
5
- embeds_many :addresses
6
4
  end
@@ -4,7 +4,6 @@ class Person
4
4
 
5
5
  field :title
6
6
  field :terms, :type => Boolean
7
- field :pets, :type => Boolean, :default => false
8
7
  field :age, :type => Integer, :default => 100
9
8
  field :dob, :type => Date
10
9
  field :mixed_drink, :type => MixedDrink
@@ -15,7 +14,6 @@ class Person
15
14
  field :score, :type => Integer
16
15
  field :blood_alcohol_content, :type => Float, :default => lambda{ 0.0 }
17
16
  field :ssn
18
- field :owner_id, :accessible => false, :type => Integer
19
17
 
20
18
  index :age
21
19
  index :addresses
@@ -26,7 +24,7 @@ class Person
26
24
 
27
25
  attr_reader :rescored
28
26
 
29
- embeds_many :addresses do
27
+ has_many :addresses do
30
28
  def extension
31
29
  "Testing"
32
30
  end
@@ -35,9 +33,9 @@ class Person
35
33
  end
36
34
  end
37
35
 
38
- embeds_many :phone_numbers, :class_name => "Phone"
36
+ has_many :phone_numbers, :class_name => "Phone"
39
37
 
40
- embeds_one :name do
38
+ has_one :name do
41
39
  def extension
42
40
  "Testing"
43
41
  end
@@ -46,7 +44,7 @@ class Person
46
44
  end
47
45
  end
48
46
 
49
- embeds_one :pet, :class_name => "Animal"
47
+ has_one :pet, :class_name => "Animal"
50
48
 
51
49
  accepts_nested_attributes_for :addresses, :reject_if => lambda { |attrs| attrs["street"].blank? }
52
50
  accepts_nested_attributes_for :name
data/spec/models/pet.rb CHANGED
@@ -2,6 +2,6 @@ class Pet
2
2
  include Mongoid::Document
3
3
  field :name
4
4
  field :weight, :type => Float, :default => 0.0
5
- embeds_many :vet_visits
6
- embedded_in :pet_owner, :inverse_of => :pet
7
- end
5
+ has_many :vet_visits
6
+ belongs_to :pet_owner, :inverse_of => :pet
7
+ end
@@ -1,6 +1,6 @@
1
1
  class PetOwner
2
2
  include Mongoid::Document
3
3
  field :title
4
- embeds_one :pet
5
- embeds_one :address
6
- end
4
+ has_one :pet
5
+ has_one :address
6
+ end
data/spec/models/phone.rb CHANGED
@@ -2,6 +2,6 @@ class Phone
2
2
  include Mongoid::Document
3
3
  field :number
4
4
  key :number
5
- embeds_one :country_code
6
- embedded_in :person, :inverse_of => :phone_numbers
7
- end
5
+ belongs_to :person, :inverse_of => :phone_numbers
6
+ has_one :country_code
7
+ end
data/spec/models/post.rb CHANGED
@@ -12,4 +12,4 @@ class Post
12
12
  where(:created_at => { "$lt" => 30.days.ago })
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -1,5 +1,5 @@
1
1
  class Translation
2
2
  include Mongoid::Document
3
3
  field :language
4
- embedded_in :name, :inverse_of => :translations
5
- end
4
+ belongs_to :name, :inverse_of => :translations
5
+ end
@@ -1,5 +1,5 @@
1
1
  class VetVisit
2
2
  include Mongoid::Document
3
3
  field :date, :type => Date
4
- embedded_in :pet, :inverse_of => :vet_visits
5
- end
4
+ belongs_to :pet, :inverse_of => :vet_visits
5
+ end
data/spec/spec_helper.rb CHANGED
@@ -8,8 +8,8 @@ require 'rubygems'
8
8
 
9
9
  gem "mocha", ">= 0.9.8"
10
10
 
11
- require "mongoid"
12
11
  require "mocha"
12
+ require "mongoid"
13
13
  require "spec"
14
14
 
15
15
  Mongoid.configure do |config|
@@ -28,4 +28,4 @@ Spec::Runner.configure do |config|
28
28
  config.after :suite do
29
29
  Mongoid.master.collections.each(&:drop)
30
30
  end
31
- end
31
+ end
@@ -134,10 +134,6 @@ describe Mongoid::Associations::BelongsToRelated do
134
134
  Mongoid::Associations::BelongsToRelated.update(nil, @child, @options).should be_nil
135
135
  end
136
136
 
137
- it "removes the association" do
138
- Mongoid::Associations::BelongsToRelated.update(nil, @child, @options)
139
- @child.person.should be_nil
140
- end
141
137
  end
142
138
 
143
139
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Mongoid::Associations::EmbeddedIn do
3
+ describe Mongoid::Associations::BelongsTo do
4
4
 
5
5
  let(:child) do
6
6
  Name.new(:first_name => "Drexel", :last_name => "Spivey")
@@ -21,7 +21,7 @@ describe Mongoid::Associations::EmbeddedIn do
21
21
  describe "#find" do
22
22
 
23
23
  before do
24
- @association = Mongoid::Associations::EmbeddedIn.new(target, options)
24
+ @association = Mongoid::Associations::BelongsTo.new(target, options)
25
25
  end
26
26
 
27
27
  context "when finding by id" do
@@ -37,7 +37,7 @@ describe Mongoid::Associations::EmbeddedIn do
37
37
  describe "#initialize" do
38
38
 
39
39
  before do
40
- @association = Mongoid::Associations::EmbeddedIn.new(target, options)
40
+ @association = Mongoid::Associations::BelongsTo.new(target, options)
41
41
  end
42
42
 
43
43
  it "sets the target" do
@@ -62,7 +62,7 @@ describe Mongoid::Associations::EmbeddedIn do
62
62
  end
63
63
  }
64
64
  @options = Mongoid::Associations::Options.new(:name => :person, :extend => @block)
65
- @association = Mongoid::Associations::EmbeddedIn.new(@parent, @options)
65
+ @association = Mongoid::Associations::BelongsTo.new(@parent, @options)
66
66
  end
67
67
 
68
68
  context "when the options have an extension" do
@@ -82,7 +82,7 @@ describe Mongoid::Associations::EmbeddedIn do
82
82
  before do
83
83
  @parent = stub
84
84
  @target = stub(:_parent => @parent)
85
- @association = Mongoid::Associations::EmbeddedIn.instantiate(@target, options)
85
+ @association = Mongoid::Associations::BelongsTo.instantiate(@target, options)
86
86
  end
87
87
 
88
88
  it "sets the parent to the target" do
@@ -98,7 +98,7 @@ describe Mongoid::Associations::EmbeddedIn do
98
98
  end
99
99
 
100
100
  it "returns nil" do
101
- Mongoid::Associations::EmbeddedIn.instantiate(@document, options).should be_nil
101
+ Mongoid::Associations::BelongsTo.instantiate(@document, options).should be_nil
102
102
  end
103
103
 
104
104
  end
@@ -107,8 +107,8 @@ describe Mongoid::Associations::EmbeddedIn do
107
107
 
108
108
  describe ".macro" do
109
109
 
110
- it "returns :embedded_in" do
111
- Mongoid::Associations::EmbeddedIn.macro.should == :embedded_in
110
+ it "returns :belongs_to" do
111
+ Mongoid::Associations::BelongsTo.macro.should == :belongs_to
112
112
  end
113
113
 
114
114
  end
@@ -116,7 +116,7 @@ describe Mongoid::Associations::EmbeddedIn do
116
116
  describe "#method_missing" do
117
117
 
118
118
  before do
119
- @association = Mongoid::Associations::EmbeddedIn.new(target, options)
119
+ @association = Mongoid::Associations::BelongsTo.new(target, options)
120
120
  end
121
121
 
122
122
  context "when method is a getter" do
@@ -156,7 +156,7 @@ describe Mongoid::Associations::EmbeddedIn do
156
156
  before do
157
157
  @name = Name.new(:first_name => "Test", :last_name => "User")
158
158
  @person = Person.new(:title => "Mrs")
159
- @association = Mongoid::Associations::EmbeddedIn.update(@person, @name, options)
159
+ @association = Mongoid::Associations::BelongsTo.update(@person, @name, options)
160
160
  end
161
161
 
162
162
  it "updates the parent document" do
@@ -179,7 +179,7 @@ describe Mongoid::Associations::EmbeddedIn do
179
179
  before do
180
180
  @address = Address.new(:street => "Broadway")
181
181
  @person = Person.new(:title => "Mrs")
182
- Mongoid::Associations::EmbeddedIn.update(@person, @address, has_many_options)
182
+ Mongoid::Associations::BelongsTo.update(@person, @address, has_many_options)
183
183
  end
184
184
 
185
185
  it "updates the parent document" do