move awesome_nested_set leaf? modification to config/initializers/10-patches.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@12682 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2014-01-20 17:54:47 +00:00
parent 89c43d24c8
commit 94e3eb2b8b
3 changed files with 19 additions and 1 deletions

View File

@ -202,3 +202,16 @@ module ActionController
end end
end end
end end
module CollectiveIdea
module Acts
module NestedSet
module Model
def leaf_with_new_record?
new_record? || leaf_without_new_record?
end
alias_method_chain :leaf?, :new_record
end
end
end
end

View File

@ -310,7 +310,7 @@ module CollectiveIdea #:nodoc:
# Returns true if this is the end of a branch. # Returns true if this is the end of a branch.
def leaf? def leaf?
new_record? || (persisted? && right.to_i - left.to_i == 1) persisted? && right.to_i - left.to_i == 1
end end
# Returns true is this is a child node # Returns true is this is a child node

View File

@ -24,6 +24,11 @@ class IssueNestedSetTest < ActiveSupport::TestCase
:enumerations, :enumerations,
:issues :issues
def test_new_record_is_leaf
i = Issue.new
assert i.leaf?
end
def test_create_root_issue def test_create_root_issue
issue1 = Issue.generate! issue1 = Issue.generate!
issue2 = Issue.generate! issue2 = Issue.generate!