Sha256: 304231e2b37b111ea974e6abdfd33b2f69c13bf993d5da4a4d369d5caaa8c1e1

Contents?: true

Size: 1.05 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.2 test/models/category_test.rb
comfortable_mexican_sofa-2.0.1 test/models/category_test.rb
comfortable_mexican_sofa-2.0.0 test/models/category_test.rb