##// END OF EJS Templates
move awesome_nested_set leaf? modification to config/initializers/10-patches.rb...
Toshi MARUYAMA -
r12407:94e3eb2b8b2d
parent child
Show More
@@ -202,3 +202,16 module ActionController
202 end
202 end
203 end
203 end
204 end
204 end
205
206 module CollectiveIdea
207 module Acts
208 module NestedSet
209 module Model
210 def leaf_with_new_record?
211 new_record? || leaf_without_new_record?
212 end
213 alias_method_chain :leaf?, :new_record
214 end
215 end
216 end
217 end
@@ -310,7 +310,7 module CollectiveIdea #:nodoc:
310
310
311 # Returns true if this is the end of a branch.
311 # Returns true if this is the end of a branch.
312 def leaf?
312 def leaf?
313 new_record? || (persisted? && right.to_i - left.to_i == 1)
313 persisted? && right.to_i - left.to_i == 1
314 end
314 end
315
315
316 # Returns true is this is a child node
316 # Returns true is this is a child node
@@ -24,6 +24,11 class IssueNestedSetTest < ActiveSupport::TestCase
24 :enumerations,
24 :enumerations,
25 :issues
25 :issues
26
26
27 def test_new_record_is_leaf
28 i = Issue.new
29 assert i.leaf?
30 end
31
27 def test_create_root_issue
32 def test_create_root_issue
28 issue1 = Issue.generate!
33 issue1 = Issue.generate!
29 issue2 = Issue.generate!
34 issue2 = Issue.generate!
General Comments 0
You need to be logged in to leave comments. Login now