Sha256: 1ff8ec98ec4ddde712239981c565df96b45d685e41039b8a8c0483793febc53f

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

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

class CategoryTest < Test::Unit::TestCase
  fixtures :contents, :categories, :categorizations, :blogs

  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
  
  def test_permalink
    assert_equal 'http://myblog.net/articles/category/software', @category.permalink_url
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typo-4.1.1 test/unit/category_test.rb
typo-5.0.1 test/unit/category_test.rb
typo-4.1 test/unit/category_test.rb
typo-5.0.2 test/unit/category_test.rb
typo-5.0 test/unit/category_test.rb