mongoid_includes 1.1.2 → 1.1.3

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.
@@ -19,5 +19,12 @@ describe Mongoid::Includes::Inclusions do
19
19
  Then { result.size == 3 }
20
20
  And { result.class == Mongoid::Includes::Inclusions }
21
21
  end
22
+
23
+ context 'prevents duplicates' do
24
+ Given {
25
+ inclusions.add(Band.relations['albums'])
26
+ }
27
+ Then { inclusions.size == 3 }
28
+ end
22
29
  end
23
30
  end
@@ -48,5 +48,19 @@ describe Mongoid::Includes::Criteria do
48
48
  And { inclusions.to_a[1].nested? && !inclusions.to_a[1].polymorphic_belongs_to? }
49
49
  And { inclusions.to_a[2].nested? && inclusions.to_a[2].polymorphic_belongs_to? }
50
50
  end
51
+
52
+ context 'works with self-referencing relations' do
53
+ Given(:metadata) { Node.relations['children'] }
54
+
55
+ When(:criteria) {
56
+ Node.includes(:children, from: :children)
57
+ }
58
+
59
+ Then { inclusions.size == 2 }
60
+ And { expect(inclusions.to_a[0].metadata).to eq(metadata) }
61
+ And { expect(inclusions.to_a[0].from).to be_nil }
62
+ And { expect(inclusions.to_a[1].metadata).to eq(metadata) }
63
+ And { expect(inclusions.to_a[1].from).to eq(:children) }
64
+ end
51
65
  end
52
66
  end
@@ -0,0 +1,6 @@
1
+ class Node
2
+ include Mongoid::Document
3
+
4
+ has_and_belongs_to_many :parents, class_name: 'Node', inverse_of: :children
5
+ has_and_belongs_to_many :children, class_name: 'Node', inverse_of: :parents
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_includes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -70,6 +70,7 @@ files:
70
70
  - spec/support/models/band.rb
71
71
  - spec/support/models/game.rb
72
72
  - spec/support/models/musician.rb
73
+ - spec/support/models/node.rb
73
74
  - spec/support/models/person.rb
74
75
  - spec/support/models/post.rb
75
76
  - spec/support/models/preference.rb
@@ -117,6 +118,7 @@ test_files:
117
118
  - spec/support/models/band.rb
118
119
  - spec/support/models/game.rb
119
120
  - spec/support/models/musician.rb
121
+ - spec/support/models/node.rb
120
122
  - spec/support/models/person.rb
121
123
  - spec/support/models/post.rb
122
124
  - spec/support/models/preference.rb