Sha256: 8abcea32027bf638bb03b87230516caa4dc66acf02022e045296a0effd4df4fa

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 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, :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

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.9 test/models/category_test.rb
comfortable_mexican_sofa-2.0.8 test/models/category_test.rb
comfortable_mexican_sofa-2.0.7 test/models/category_test.rb
comfortable_mexican_sofa-2.0.6 test/models/category_test.rb
comfortable_mexican_sofa-2.0.5 test/models/category_test.rb
comfortable_mexican_sofa-2.0.4 test/models/category_test.rb
comfortable_mexican_sofa-2.0.3 test/models/category_test.rb