Class: ActionLinksTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



4
5
6
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 4

def setup
  @links = ActiveScaffold::DataStructures::ActionLinks.new
end

#test_add_and_findObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 8

def test_add_and_find
  # test adding with a shortcut
  @links.add 'foo/bar'

  assert_equal 1, @links.find_all{true}.size
  assert_equal 'foo/bar', @links.find_all{true}[0].action
  assert_equal 'foo/bar', @links['foo/bar'].action

  # test adding an ActionLink object directly
  @links.add ActiveScaffold::DataStructures::ActionLink.new('hello/world')

  assert_equal 2, @links.find_all{true}.size

  # test the << alias
  @links << 'a/b'

  assert_equal 3, @links.find_all{true}.size
end

#test_array_accessObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 27

def test_array_access
  @link1 = ActiveScaffold::DataStructures::ActionLink.new 'foo/bar'
  @link2 = ActiveScaffold::DataStructures::ActionLink.new 'hello_world'

  @links.add @link1
  @links.add @link2

  assert_equal @link1, @links[@link1.action]
  assert_equal @link2, @links[@link2.action]
end

#test_cloningObject



44
45
46
47
48
49
50
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 44

def test_cloning
  @links.add 'foo/bar'
  @links_copy = @links.clone

  assert !@links.equal?(@links_copy)
  assert !@links['foo/bar'].equal?(@links_copy['foo/bar'])
end

#test_deleteObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 64

def test_delete
  @links.add 'foo'
  @links.add 'bar'

  @links.delete :foo
  assert @links['foo'].nil?
  begin
    @links.delete :foo
  @links.delete 'foo'
  rescue
    assert false, "deleting from action links when item doesn't exist should not throw an error"
  end
  assert !@links['bar'].nil?
end

#test_eachObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 52

def test_each
  @links.add 'foo', :type => :table
  @links.add 'bar', :type => :record

  @links.each :table do |link|
    assert_equal 'foo', link.action
  end
  @links.each :record do |link|
    assert_equal 'bar', link.action
  end
end

#test_emptyObject



38
39
40
41
42
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb', line 38

def test_empty
  assert @links.empty?
  @links.add 'a'
  assert !@links.empty?
end