ramdiv-mongo_mapper_acts_as_tree 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -30,7 +30,7 @@ module MongoMapper
30
30
  key depth_field, Integer, :default => 0
31
31
 
32
32
  after_save :move_children
33
- before_save :will_save_tree
33
+ validate :will_save_tree
34
34
  before_destroy :destroy_descendants
35
35
  ensure_index([path_field, 1])
36
36
  end
@@ -62,7 +62,9 @@ module MongoMapper
62
62
  end
63
63
 
64
64
  def will_save_tree
65
- !@_cyclic
65
+ if @_cyclic
66
+ errors.add(:base, "Can't be children of a descendant")
67
+ end
66
68
  end
67
69
 
68
70
  def fix_position
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ramdiv-mongo_mapper_acts_as_tree}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jakob Vidmar"]
data/test/test_tree.rb CHANGED
@@ -121,7 +121,7 @@ class TestMongomapperActsAsTree < Test::Unit::TestCase
121
121
  assert @root_2.descendants.include?(@child_2_1)
122
122
  end
123
123
 
124
- should "check agains cyclic graph" do
124
+ should "check against cyclic graph" do
125
125
  @root_1.parent = @child_2_1
126
126
  assert !@root_1.save
127
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramdiv-mongo_mapper_acts_as_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Vidmar