Sha256: 4cd604c0c79c571cec26825b1662d8cd864c3d016d0a71c59ec78136e4e18260

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class CategoryTest < Test::Unit::TestCase
  fixtures :contents, :categories, :articles_categories

  def setup
    @category = Category.find(1)
  end

  def test_truth
    assert_kind_of Category,  @category
  end

  def test_find_all_with_article_counters
    c = Category.find_all_with_article_counters

    assert_equal categories(:software), c[0]
    assert_equal categories(:hardware), c[1]
    assert_equal categories(:personal), c[2]

    assert_equal 1, c[0].article_counter
    assert_equal 1, c[1].article_counter
    assert_equal 3, c[2].article_counter
  end

  def test_reorder
    assert_equal categories(:software), Category.find(:first, :order => :position)
    Category.reorder([categories(:personal).id, categories(:hardware).id, categories(:software).id])
    assert_equal categories(:personal), Category.find(:first, :order => :position)
  end

  def test_reorder_alpha
    assert_equal categories(:software), Category.find(:first, :order => :position)
    Category.reorder_alpha
    assert_equal categories(:hardware), Category.find(:first, :order => :position)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 test/unit/category_test.rb
typo-3.99.1 test/unit/category_test.rb
typo-3.99.2 test/unit/category_test.rb
typo-3.99.3 test/unit/category_test.rb
typo-4.0.0 test/unit/category_test.rb
typo-4.0.2 test/unit/category_test.rb
typo-3.99.4 test/unit/category_test.rb
typo-4.0.1 test/unit/category_test.rb
typo-4.0.3 test/unit/category_test.rb