File: test_callback.rb

package info (click to toggle)
ruby-activeldap 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,588 kB
  • sloc: ruby: 18,143; sh: 12; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'al-test-utils'

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

  priority :must
  def test_new
    initialized_entries = []
    @group_class.module_eval do
      after_initialize do
        initialized_entries << self
      end
    end
    assert_equal([], initialized_entries)
    new_group = @group_class.new(:cn => "new-cn")
    assert_equal([new_group.cn].sort,
                 initialized_entries.collect {|g| g.cn}.sort)
  end

  priority :normal
  def test_find
    make_temporary_group do |group|
      found_entries = []
      initialized_entries = []
      @group_class.module_eval do
        prepend ActiveLdap::Callbacks::CallbackedInstantiatable
        after_find do
          found_entries << self
        end
        after_initialize do
          initialized_entries << self
        end
      end

      assert_equal([], found_entries)
      assert_equal([], initialized_entries)

      found_group = @group_class.find(group.dn)

      assert_equal([found_group.cn].sort, found_entries.collect {|g| g.cn}.sort)
      assert_equal([found_group.cn].sort,
                   initialized_entries.collect {|g| g.cn}.sort)
    end
  end
end