]> source.dussan.org Git - redmine.git/commitdiff
move awesome_nested_set leaf? modification to config/initializers/10-patches.rb
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 20 Jan 2014 17:54:47 +0000 (17:54 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 20 Jan 2014 17:54:47 +0000 (17:54 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12682 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/10-patches.rb
lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
test/unit/issue_nested_set_test.rb

index d186bcdc4b24cb7d1807cf5c5bad97bc5323f99d..0ddbcdd06cbc3787b49195e3dcbeb9895e6654a9 100644 (file)
@@ -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
index 1a7ceae15d088e6187f9014b5eeeb12be7701498..9832a655b45d1caa8460b0c37a204af2cf41e891 100644 (file)
@@ -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
index 3c611be281140a4f7dbcf9a38672a12138d78028..899344937bf1db3da5ff146fc99a9078a4bfde95 100644 (file)
@@ -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!