Class: CollectiveIdea::Acts::NestedSet::AwesomeNestedSetTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
Helper
Defined in:
vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb

Instance Method Summary

Methods included from Helper

#nested_set_options

Instance Method Details

- (Object) test_nested_set_options



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb', line 10

def test_nested_set_options
  expected = [
    [" Top Level", 1],
    ["- Child 1", 2],
    ['- Child 2', 3],
    ['-- Child 2.1', 4],
    ['- Child 3', 5],
    [" Top Level 2", 6]
  ]
  actual = nested_set_options(Category) do |c|
    "#{'-' * c.level} #{c.name}"
  end
  assert_equal expected, actual
end

- (Object) test_nested_set_options_with_mover



25
26
27
28
29
30
31
32
33
34
35
36
# File 'vendor/plugins/awesome_nested_set/test/awesome_nested_set/helper_test.rb', line 25

def test_nested_set_options_with_mover
  expected = [
    [" Top Level", 1],
    ["- Child 1", 2],
    ['- Child 3', 5],
    [" Top Level 2", 6]
  ]
  actual = nested_set_options(Category, categories(:child_2)) do |c|
    "#{'-' * c.level} #{c.name}"
  end
  assert_equal expected, actual
end