Sha256: 7a8bc21596b3e9823584a44ebe9fbd037250b134d8fef90747c98a1e36b85312

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

require_relative '../test_helper'

class CmsCategoryTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    Comfy::Cms::Category.all.each do |category|
      assert category.valid?, category.errors.full_messages.to_s
    end
  end
  
  def test_validation
    category = Comfy::Cms::Category.new
    assert category.invalid?
    assert_has_errors_on category, [:site_id, :label, :categorized_type]
  end
  
  def test_creation
    assert_difference 'Comfy::Cms::Category.count' do
      comfy_cms_sites(:default).categories.create(
        :label => 'Test Category',
        :categorized_type => 'Comfy::Cms::Snippet'
      )
    end
  end
  
  def test_destruction
    category = comfy_cms_categories(:default)
    assert_equal 1, category.categorizations.count
    assert_difference ['Comfy::Cms::Category.count', 'Comfy::Cms::Categorization.count'], -1 do
      category.destroy
    end
  end
  
  def test_scope_of_type
    assert_equal 1, Comfy::Cms::Category.of_type('Comfy::Cms::File').count
    assert_equal 0, Comfy::Cms::Category.of_type('Invalid').count
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.12.11 test/models/category_test.rb
comfortable_mexican_sofa-1.12.10 test/models/category_test.rb
comfortable_mexican_sofa-1.12.9 test/models/category_test.rb
comfortable_mexican_sofa-1.12.8 test/models/category_test.rb
comfortable_mexican_sofa-1.12.7 test/models/category_test.rb
comfortable_mexican_sofa-1.12.6 test/models/category_test.rb
comfortable_mexican_sofa-1.12.5 test/models/category_test.rb
comfortable_mexican_sofa-1.12.4 test/models/category_test.rb
comfortable_mexican_sofa-1.12.3 test/models/category_test.rb
comfortable_mexican_sofa-1.12.2 test/models/category_test.rb
comfortable_mexican_sofa-1.12.1 test/models/category_test.rb
comfortable_mexican_sofa-1.12.0 test/models/category_test.rb