Sha256: 08c809f610bd7e9b2c5f821de3f43699bf124d44761451e8b63e397398847ddf

Contents?: true

Size: 1.57 KB

Versions: 9

Compression:

Stored size: 1.57 KB

Contents

require 'test_helper'

module Guts
  class TypeTest < ActiveSupport::TestCase
    test 'should not create without title' do
      type = Type.new

      assert_not type.save
    end

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

      assert_not type.save
    end

    test 'should create slug for title' do
      type       = Type.new
      type.title = 'i am a type good sir'
      type.save

      assert_equal 'i-am-a-type-good-sir', type.slug
    end

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

      type = guts_types :page_type
      assert_equal 'Page', type.navigatable_format
    end

    test 'should return contents for type' do
      type    = guts_types :page_type
      content = guts_contents :test_page

      assert_includes type.contents, content
    end

    test 'should return metafields for type' do
      type = guts_types :page_type

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

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

    test 'should have site id as null in scope' do
      sql = Type.all.to_sql
      assert sql.include?('"site_id" IS NULL')
    end

    test 'should have site id as integer in scope' do
      site = guts_sites(:nondefault_site)
      Site.current_id = site.id
      sql = Type.all.to_sql
      Site.current_id = nil

      assert sql.include?(site.id.to_s)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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