Class: ActionColumnsTest

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

Instance Method Summary collapse

Instance Method Details

#setupObject



12
13
14
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 12

def setup
  @columns = ActiveScaffold::DataStructures::ActionColumns.new(:a, :b)
end

#test_addObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 49

def test_add
  # try adding a simple column using a string
  assert !@columns.include?(:c)
  @columns.add 'c'
  assert @columns.include?(:c)

  # try adding a simple column using a symbol
  assert !@columns.include?(:d)
  @columns.add :d
  assert @columns.include?(:d)

  # test that << also adds
  assert !@columns.include?(:e)
  @columns << :e
  assert @columns.include?(:e)

  # try adding an array of columns
  assert !@columns.include?(:f)
  @columns.add [:f, :g]
  assert @columns.include?(:f)
  assert @columns.include?(:g)

end

#test_add_subgroupObject



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 77

def test_add_subgroup
  # first, use @columns.add directly
  @c2 = ActiveScaffold::DataStructures::ActionColumns.new
  @columns.add @c2
  assert @columns.any? { |c| c == @c2 }

  # then use the shortcut
  @columns.add_subgroup 'foo' do
  end
  assert @columns.any? { |c| c.respond_to? :label and c.label == 'foo' }
end

#test_block_configObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 89

def test_block_config
  @columns.configure do |config|
    # we may use the config argument
    config.add :c
    # or we may not
    exclude :b
    add_subgroup 'my subgroup' do
      add :e
    end
  end

  assert @columns.include?(:c)
  assert !@columns.include?(:b)
  @columns.each { |c|
    next unless c.is_a? ActiveScaffold::DataStructures::Columns
    assert c.include?(:e)
    assert_equal 'my subgroup', c.name
  }
end

#test_excludeObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 29

def test_exclude
  # exclude with a symbol
  assert @columns.include?(:b)
  @columns.exclude :b
  assert !@columns.include?(:b)

  # exclude with a string
  assert @columns.include?(:a)
  @columns.exclude 'a'
  assert !@columns.include?(:a)
end

#test_exclude_arrayObject



41
42
43
44
45
46
47
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 41

def test_exclude_array
  # exclude with a symbol
  assert @columns.include?(:b)
  @columns.exclude [:a, :b]
  assert !@columns.include?(:b)
  assert !@columns.include?(:a)
end

#test_includeObject



109
110
111
112
113
114
115
116
117
118
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 109

def test_include
  @columns.add_subgroup 'foo' do
    add :c
  end

  assert @columns.include?(:a)
  assert @columns.include?(:b)
  assert @columns.include?(:c)
  assert !@columns.include?(:d)
end

#test_initializationObject



23
24
25
26
27
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 23

def test_initialization
  assert @columns.include?(:a)
  assert @columns.include?(:b)
  assert !@columns.include?(:c)
end

#test_labelObject



16
17
18
19
20
21
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 16

def test_label
  assert_nothing_raised do
    @columns.label = 'foo';
  end
  assert @columns.label == 'foo'
end

#test_lengthObject



73
74
75
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb', line 73

def test_length
  assert_equal 2, @columns.length
end