Sha256: 4dd98f827f34fac66733c7cea35e41aa5e5b4cae11dc44cfc4de36ea0b1f49a2

Contents?: true

Size: 1013 Bytes

Versions: 7

Compression:

Stored size: 1013 Bytes

Contents

require_relative '../test_helper'

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.11.2 test/models/category_test.rb
comfortable_mexican_sofa-1.11.1 test/models/category_test.rb
comfortable_mexican_sofa-1.11.0 test/models/category_test.rb
comfortable_mexican_sofa-1.10.3 test/models/category_test.rb
comfortable_mexican_sofa-1.10.2 test/models/category_test.rb
comfortable_mexican_sofa-1.10.1 test/models/category_test.rb
comfortable_mexican_sofa-1.10.0 test/models/category_test.rb