Sha256: c2550085d72d7260e43176379d29aff76e542b1a6d93e7d7c2e09d8630c0689e

Contents?: true

Size: 1.85 KB

Versions: 98

Compression:

Stored size: 1.85 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')

class ActionLinksTest < Test::Unit::TestCase
  def setup
    @links = ActiveScaffold::DataStructures::ActionLinks.new
  end

  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

  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

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

  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

  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
  
  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
end

Version data entries

98 entries across 98 versions & 2 rubygems

Version Path
six-updater-web-0.24.15 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.14 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.13 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.12 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.11 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.10 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.9 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.8 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.7 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.6 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.5 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
brisk-bills-0.7.0 vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.4 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.3 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.2 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.1 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.24.0 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.23.7 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.23.6 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
six-updater-web-0.23.5 lib/six-updater-web/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb