summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-20 17:54:47 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2014-01-20 17:54:47 +0000
commit94e3eb2b8b2d2cbd45ae5714ab90b5ca7bfe5097 (patch)
tree8e9ab370fd1b313f89bab8324e16721b9f388462
parent89c43d24c82f6b58e8838bb92ddf6808cef6828c (diff)
downloadredmine-94e3eb2b8b2d2cbd45ae5714ab90b5ca7bfe5097.tar.gz
redmine-94e3eb2b8b2d2cbd45ae5714ab90b5ca7bfe5097.zip
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
-rw-r--r--config/initializers/10-patches.rb13
-rw-r--r--lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb2
-rw-r--r--test/unit/issue_nested_set_test.rb5
3 files changed, 19 insertions, 1 deletions
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
index d186bcdc4..0ddbcdd06 100644
--- a/config/initializers/10-patches.rb
+++ b/config/initializers/10-patches.rb
@@ -202,3 +202,16 @@ module ActionController
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
diff --git a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
index 1a7ceae15..9832a655b 100644
--- a/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
+++ b/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
@@ -310,7 +310,7 @@ module CollectiveIdea #:nodoc:
# Returns true if this is the end of a branch.
def leaf?
- new_record? || (persisted? && right.to_i - left.to_i == 1)
+ persisted? && right.to_i - left.to_i == 1
end
# Returns true is this is a child node
diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb
index 3c611be28..899344937 100644
--- a/test/unit/issue_nested_set_test.rb
+++ b/test/unit/issue_nested_set_test.rb
@@ -24,6 +24,11 @@ class IssueNestedSetTest < ActiveSupport::TestCase
:enumerations,
:issues
+ def test_new_record_is_leaf
+ i = Issue.new
+ assert i.leaf?
+ end
+
def test_create_root_issue
issue1 = Issue.generate!
issue2 = Issue.generate!