Sha256: 7f62a4a0ca788bcb5a93a8255334ff9e184757d480e5b8f5c9f97248d21d0679

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'

module Guts
  class CategoryTest < ActiveSupport::TestCase
    test 'should not create without title' do
      category = Category.new

      assert_not category.save
    end

    test 'should not create with title less than three characters' do
      category       = Category.new
      category.title = '12'

      assert_not category.save
    end

    test 'should create slug for title' do
      category       = Category.new
      category.title = 'Super Duper Category!'
      category.save

      assert_equal 'super-duper-category', category.slug
    end

    test 'should return navigatable format' do
      assert_equal ':title', Category.navigatable_opts[:format]
      assert_equal [:title], Category.navigatable_opts[:variables]

      category = guts_categories :test_category
      assert_equal 'Super Category!', category.navigatable_format
    end

    test 'should return contents for category' do
      category = guts_categories :test_category

      assert_operator category.contents.size, :>, 0
    end

    test 'should return metafields for category' do
      category = guts_categories :test_category

      assert_operator category.metafields.size, :>, 0
    end

    test 'category should be multisite compatible' do
      assert Category.all.to_sql.include?('site_id')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
guts-3.1.2 test/models/guts/category_test.rb
guts-3.1.1 test/models/guts/category_test.rb
guts-3.1.0 test/models/guts/category_test.rb
guts-3.0.1 test/models/guts/category_test.rb
guts-3.0.0 test/models/guts/category_test.rb
guts-2.1.0 test/models/guts/category_test.rb
guts-2.0.2 test/models/guts/category_test.rb
guts-2.0.1 test/models/guts/category_test.rb
guts-2.0.0 test/models/guts/category_test.rb