Sha256: 232977cab00feb185379957ea4fcac5c700f654d42e145668d222744792655bb

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

# encoding: utf-8

require File.dirname(__FILE__) + '/test_helper'

class STIModelTest < Test::Unit::TestCase

  context "A slugged model using single table inheritance" do

    setup do
      Novel.friendly_id_options = FriendlyId::DEFAULT_OPTIONS.merge(:method => :title, :use_slug => true)
      @novel = Novel.new :title => "Test novel"
      @novel.save!
    end

    teardown do
      Novel.delete_all
      Slug.delete_all
    end

    should "have a slug" do
      assert_not_nil @novel.slug
    end

    context "found by its friendly id" do

      setup do
        @novel = Novel.find(@novel.friendly_id)
      end

      should "not indicate that it has a better id" do
        assert !@novel.has_better_id?
      end

    end


    context "found by its numeric id" do

      setup do
        @novel = Novel.find(@novel.id)
      end

      should "indicate that it has a better id" do
        assert @novel.has_better_id?
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
friendly_id-2.2.5 test/sti_test.rb
friendly_id-2.2.4 test/sti_test.rb
friendly_id-2.2.3 test/sti_test.rb