Sha256: 9f7fd097f8aaa573b7bf6cccdc815f2abbb4c2385ec3284566835976132c2a2c

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

class CategoryTest < ActiveSupport::TestCase

  setup do
    @category = Category.new :title => 'Test category'
  end  
  
  test "truth" do
    assert_kind_of Class, Category
  end
  
  test 'should has page_parts_definitions' do
    assert Category.respond_to?(:page_parts_definitions)
  end
  
  test "should save page parts with new_record" do
    value = "Sidebar content"
    @category.sidebar = value
    
    assert_equal @category.page_part(:sidebar).content, value
    assert_equal @category.page_part(:content).content, nil
    
    assert_difference('PagePart.count', 2) do
      @category.save
    end
  end
  
  test "should load page parts into record" do
    @category.sidebar = "Sidebar"
    @category.content = "Main"
    @category.save
    
    @category.reload
    
    assert_equal @category.sidebar, "Sidebar"
    assert_equal @category.content, "Main"
  end
  
  test "should raise error on not registered page part" do
    assert_raise(NoMethodError) do
      @category.wrong_method
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_parts-0.0.2 test/models/category_test.rb
page_parts-0.0.1 test/models/category_test.rb