mongoid-tree 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 839d3ab28af5b3c0b2c9d4050f1c6940c444bd29
4
- data.tar.gz: c9d5033394a48416907f5500fa990b8bf6d96f6e
3
+ metadata.gz: 2efbc10260f22d9266cedf4f51ea25db0e7385e0
4
+ data.tar.gz: e07926dc9a02d5c22f8f49abd91305a94d96e3f3
5
5
  SHA512:
6
- metadata.gz: a85f4ac7c49b858afd70a696aa0595df7af63ae85f21b15330cc3b88b3e277ee30cec3f1fe43dad34246126d3dec8f1da701a162430878f0ae30ef363e569696
7
- data.tar.gz: 458d20a30a99b0940c882e14bc080b5c2efaeedbc90f92cc28eae56ee835795194f8695d3c9c9a55e5f0e6977a4ef7eec97d19860b845b9f3656b15d475848f1
6
+ metadata.gz: 0328b760885d2a4442a1f4dedfcf741f6cd18f4a1902924287a06ca41fef76f7c927d8a110dfd869350fc02dc0aefde9381652d7d5f1dd25dad199c5b7b19491
7
+ data.tar.gz: 24970a25867dc1550a658f569a84c4e596d53748268ab944a8424c2367f9221537f39cb04736aaf944992af541adb7a514fe43e4daddf68b919a8430ae279ee1
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Benedikt Deicke
1
+ Copyright (c) 2010-2013 Benedikt Deicke
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -212,4 +212,4 @@ If you like mongoid-tree and want to support the development, I would appreciate
212
212
 
213
213
  ## Copyright
214
214
 
215
- Copyright (c) 2010-2012 Benedikt Deicke. See LICENSE for details.
215
+ Copyright (c) 2010-2013 Benedikt Deicke. See LICENSE for details.
data/lib/mongoid/tree.rb CHANGED
@@ -272,7 +272,11 @@ module Mongoid
272
272
  #
273
273
  # @return [Mongoid::Criteria] Mongoid criteria to retrieve the documents ancestors
274
274
  def ancestors
275
- base_class.or(parent_ids.map { |id| { :_id => id } })
275
+ if parent_ids.any?
276
+ base_class.or(parent_ids.map { |id| { :_id => id } })
277
+ else
278
+ base_class.where(:_id.in => [])
279
+ end
276
280
  end
277
281
 
278
282
  ##
@@ -288,6 +288,11 @@ describe Mongoid::Tree do
288
288
 
289
289
  expect(subchild.ancestors.to_a).to eq([child, root])
290
290
  end
291
+
292
+ it 'should return nothing when there are no ancestors' do
293
+ root = Node.new(:name => 'root')
294
+ expect(root.ancestors).to be_empty
295
+ end
291
296
  end
292
297
 
293
298
  describe '#ancestors_and_self' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benedikt Deicke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-14 00:00:00.000000000 Z
11
+ date: 2013-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -94,7 +94,8 @@ files:
94
94
  - Gemfile
95
95
  - .rspec
96
96
  homepage: https://github.com/benedikt/mongoid-tree
97
- licenses: []
97
+ licenses:
98
+ - MIT
98
99
  metadata: {}
99
100
  post_install_message:
100
101
  rdoc_options: []