Sha256: 6785cdd79fcc9a4a1d546408cab66b55d4dbdfa56ce4d5c5947367bcaf7abba6

Contents?: true

Size: 1.63 KB

Versions: 36

Compression:

Stored size: 1.63 KB

Contents

require 'al-test-utils'

class TestActsAsTree < Test::Unit::TestCase
  include AlTestUtils

  priority :must

  priority :normal
  def test_children
    users = ou_class.find("Users")
    assert_equal([], users.children.collect(&:ou))

    sub_users = users.class.new("SubUsers")
    users.children << sub_users
    assert_equal(["SubUsers"], users.children.collect(&:ou))

    users = ou_class.find("Users")
    assert_equal(["SubUsers"], users.children.collect(&:ou))

    assert_equal(dn("ou=SubUsers,#{users.dn}"),
                 sub_users.dn)

    assert(ou_class.exists?("SubUsers"))
    users.children.replace([])
    assert(!ou_class.exists?("SubUsers"))
    assert_equal([], users.children.collect(&:ou))
  end

  def test_parent
    users = ou_class.find("Users")
    assert_equal([], users.children.collect(&:ou))

    sub_users = users.class.new("SubUsers")
    sub_users.parent = users
    assert_equal(dn("ou=SubUsers,#{users.dn}"),
                 sub_users.dn)
    assert_equal(["SubUsers"], users.children.collect(&:ou))

    sub_users = ou_class.find("SubUsers")
    assert_equal(users.dn, sub_users.parent.dn)

    assert_raises(ArgumentError) do
      sub_users.parent = nil
    end

    make_ou("OtherUsers")
    other_users = ou_class.find("OtherUsers")
    assert_equal([], other_users.children.collect(&:ou))

    sub_users.parent = other_users.dn
    assert_equal(dn("ou=SubUsers,#{other_users.dn}"),
                 sub_users.dn)

    other_users.clear_association_cache
    assert_equal(["SubUsers"], other_users.children.collect(&:ou))

    users.clear_association_cache
    assert_equal([], users.children.collect(&:ou))
  end
end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
activeldap-7.2.1 test/test_acts_as_tree.rb
activeldap-7.2.0 test/test_acts_as_tree.rb
activeldap-7.0.0 test/test_acts_as_tree.rb
activeldap-6.1.0 test/test_acts_as_tree.rb
activeldap-6.0.4 test/test_acts_as_tree.rb
activeldap-6.0.3 test/test_acts_as_tree.rb
activeldap-6.0.2 test/test_acts_as_tree.rb
activeldap-6.0.1 test/test_acts_as_tree.rb
activeldap-6.0.0 test/test_acts_as_tree.rb
activeldap-5.2.4 test/test_acts_as_tree.rb
activeldap-5.2.3 test/test_acts_as_tree.rb
activeldap-5.2.2 test/test_acts_as_tree.rb
activeldap-5.2.1 test/test_acts_as_tree.rb
activeldap-5.2.0 test/test_acts_as_tree.rb
activeldap-5.1.1 test/test_acts_as_tree.rb
activeldap-5.1.0 test/test_acts_as_tree.rb
activeldap-3.2.3 test/test_acts_as_tree.rb
powerhome-activeldap-3.2.3 test/test_acts_as_tree.rb
activeldap-4.0.6 test/test_acts_as_tree.rb
activeldap-4.0.5 test/test_acts_as_tree.rb