mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 11:25:55 +01:00
Remove wrong copyright headers from acts_as_tree plugin (#37730).
git-svn-id: https://svn.redmine.org/redmine/trunk@22600 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1,21 +1,4 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Redmine - project management software
|
|
||||||
# Copyright (C) 2006-2023 Jean-Philippe Lang
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
require_relative 'lib/active_record/acts/tree'
|
require_relative 'lib/active_record/acts/tree'
|
||||||
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
|
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
|
||||||
|
|||||||
@@ -1,22 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Redmine - project management software
|
|
||||||
# Copyright (C) 2006-2023 Jean-Philippe Lang
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module Acts
|
module Acts
|
||||||
module Tree
|
module Tree
|
||||||
|
|||||||
@@ -1,22 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Redmine - project management software
|
|
||||||
# Copyright (C) 2006-2023 Jean-Philippe Lang
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
@@ -62,7 +45,7 @@ end
|
|||||||
class Mixin < ActiveRecord::Base
|
class Mixin < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class TreeMixin < Mixin
|
class TreeMixin < Mixin
|
||||||
acts_as_tree :foreign_key => "parent_id", :order => "id"
|
acts_as_tree :foreign_key => "parent_id", :order => "id"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -76,7 +59,7 @@ class RecursivelyCascadedTreeMixin < Mixin
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TreeTest < Test::Unit::TestCase
|
class TreeTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
setup_db
|
setup_db
|
||||||
@root1 = TreeMixin.create!
|
@root1 = TreeMixin.create!
|
||||||
@@ -165,12 +148,12 @@ class TreeTest < Test::Unit::TestCase
|
|||||||
assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
|
assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
|
||||||
assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
|
assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
|
||||||
assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
|
assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TreeTestWithEagerLoading < Test::Unit::TestCase
|
class TreeTestWithEagerLoading < Test::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
teardown_db
|
teardown_db
|
||||||
setup_db
|
setup_db
|
||||||
@root1 = TreeMixin.create!
|
@root1 = TreeMixin.create!
|
||||||
@@ -179,9 +162,9 @@ class TreeTestWithEagerLoading < Test::Unit::TestCase
|
|||||||
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
||||||
@root2 = TreeMixin.create!
|
@root2 = TreeMixin.create!
|
||||||
@root3 = TreeMixin.create!
|
@root3 = TreeMixin.create!
|
||||||
|
|
||||||
@rc1 = RecursivelyCascadedTreeMixin.create!
|
@rc1 = RecursivelyCascadedTreeMixin.create!
|
||||||
@rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
|
@rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
|
||||||
@rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
|
@rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
|
||||||
@rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
|
@rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
|
||||||
end
|
end
|
||||||
@@ -189,36 +172,36 @@ class TreeTestWithEagerLoading < Test::Unit::TestCase
|
|||||||
def teardown
|
def teardown
|
||||||
teardown_db
|
teardown_db
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_association_loading
|
def test_eager_association_loading
|
||||||
roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
|
roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
|
||||||
assert_equal [@root1, @root2, @root3], roots
|
assert_equal [@root1, @root2, @root3], roots
|
||||||
assert_no_queries do
|
assert_no_queries do
|
||||||
assert_equal 2, roots[0].children.size
|
assert_equal 2, roots[0].children.size
|
||||||
assert_equal 0, roots[1].children.size
|
assert_equal 0, roots[1].children.size
|
||||||
assert_equal 0, roots[2].children.size
|
assert_equal 0, roots[2].children.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
|
def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
|
||||||
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
|
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
|
||||||
assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
|
assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
|
def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
|
||||||
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
|
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
|
||||||
assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
|
assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
|
def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
|
||||||
leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
|
leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
|
||||||
assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
|
assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TreeTestWithoutOrder < Test::Unit::TestCase
|
class TreeTestWithoutOrder < Test::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
setup_db
|
setup_db
|
||||||
@root1 = TreeMixinWithoutOrder.create!
|
@root1 = TreeMixinWithoutOrder.create!
|
||||||
@root2 = TreeMixinWithoutOrder.create!
|
@root2 = TreeMixinWithoutOrder.create!
|
||||||
@@ -231,8 +214,8 @@ class TreeTestWithoutOrder < Test::Unit::TestCase
|
|||||||
def test_root
|
def test_root
|
||||||
assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
|
assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_roots
|
def test_roots
|
||||||
assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
|
assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user