mongo_mapper_acts_as_tree 0.3 → 0.3.1

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.
@@ -45,6 +45,10 @@ module MongoMapper
45
45
  self.class.where('#{configuration[:foreign_key].to_s.pluralize}' => self.id).all
46
46
  end
47
47
 
48
+ def depth
49
+ self.#{configuration[:foreign_key].to_s.pluralize}.count
50
+ end
51
+
48
52
  EOV
49
53
  end
50
54
  end
@@ -2,7 +2,7 @@
2
2
  module MongoMapper
3
3
  module Plugins
4
4
  module ActsAsTree
5
- Version = '0.3'
5
+ Version = '0.3.1'
6
6
  end
7
7
  end
8
8
  end
@@ -104,6 +104,15 @@ class TreeTest < ActiveSupport::TestCase
104
104
  assert_equal [@root1, @root2, @root3], TreeMixin.roots
105
105
  end
106
106
 
107
+ def test_depth
108
+ assert_equal 0, @root1.depth
109
+ assert_equal 0, @root2.depth
110
+ assert_equal 0, @root3.depth
111
+ assert_equal 1, @root_child1.depth
112
+ assert_equal 1, @root_child2.depth
113
+ assert_equal 2, @child1_child.depth
114
+ end
115
+
107
116
  def test_siblings
108
117
  assert_equal [@root2, @root3], @root1.siblings
109
118
  assert_equal [@root_child2], @root_child1.siblings
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper_acts_as_tree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- version: "0.3"
9
+ - 1
10
+ version: 0.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Tomas Celizna