File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ module Ordering
47
47
#
48
48
# @return [Mongoid::Criteria] Mongoid criteria to retrieve the document's ancestors
49
49
def ancestors
50
- base_class . unscoped . where ( :_id . in => parent_ids )
50
+ base_class . unscoped { super }
51
51
end
52
52
53
53
##
Original file line number Diff line number Diff line change 177
177
178
178
node ( :leaf ) . ancestors . to_a . should == [ node ( :root ) , node ( :level_1_b ) , node ( :level_2_a ) ]
179
179
end
180
+
181
+ it "should return the ancestors in correct order even after rearranging" do
182
+ setup_tree <<-ENDTREE
183
+ - root:
184
+ - child:
185
+ - subchild
186
+ ENDTREE
187
+
188
+ child = node ( :child ) ; child . parent = nil ; child . save!
189
+ root = node ( :root ) ; root . parent = node ( :child ) ; root . save!
190
+ subchild = node ( :subchild ) ; subchild . parent = root ; subchild . save!
191
+
192
+ subchild . ancestors . to_a . should == [ child , root ]
193
+ end
180
194
end
181
195
end
182
196
You can’t perform that action at this time.
0 commit comments