public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / test / unit / assigned_section_test.rb
100644 25 lines (20 sloc) 0.821 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require File.dirname(__FILE__) + '/../test_helper'
 
class AssignedSectionTest < Test::Unit::TestCase
  fixtures :contents, :sections, :assigned_sections
 
  def test_should_not_allow_duplicate_assigned_sections
    assert_equal 1, contents(:another).assigned_sections.length
    assert !contents(:another).assigned_sections.build(:section => sections(:home)).valid?
  end
 
  def test_should_increment_articles_count_cache
    assert_difference sections(:home), :articles_count do
      AssignedSection.create! :article => contents(:site_map), :section => sections(:home)
      sections(:home).reload
    end
  end
  
  def test_should_decrement_articles_count_cache
    assert_difference sections(:home), :articles_count, -1 do
      assigned_sections(:welcome_home).destroy
      sections(:home).reload
    end
  end
end