Sha256: 66fca5d8d95ffa66eef1939c798813599537ef6876b4e4617f80affef6368f1d

Contents?: true

Size: 1.3 KB

Versions: 11

Compression:

Stored size: 1.3 KB

Contents

require File.expand_path("../helper.rb", __FILE__)

class StiTest < MiniTest::Unit::TestCase

  include FriendlyId::Test
  include FriendlyId::Test::Shared::Core
  include FriendlyId::Test::Shared::Slugged

  class Journalist < ActiveRecord::Base
    extend FriendlyId
    friendly_id :name, :use => :slugged
  end

  class Editorialist < Journalist
  end

  def model_class
    Editorialist
  end

  test "friendly_id should accept a base and a hash with single table inheritance" do
    abstract_klass = Class.new(ActiveRecord::Base) do
      extend FriendlyId
      friendly_id :foo, :use => :slugged, :slug_column => :bar
    end
    klass = Class.new(abstract_klass)
    assert klass < FriendlyId::Slugged
    assert_equal :foo, klass.friendly_id_config.base
    assert_equal :bar, klass.friendly_id_config.slug_column
  end


  test "friendly_id should accept a block with single table inheritance" do
    abstract_klass = Class.new(ActiveRecord::Base) do
      extend FriendlyId
      friendly_id :foo do |config|
        config.use :slugged
        config.base = :foo
        config.slug_column = :bar
      end
    end
    klass = Class.new(abstract_klass)
    assert klass < FriendlyId::Slugged
    assert_equal :foo, klass.friendly_id_config.base
    assert_equal :bar, klass.friendly_id_config.slug_column
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
friendly_id-4.0.0 test/sti_test.rb
friendly_id-4.0.0.rc2 test/sti_test.rb
friendly_id-4.0.0.rc1 test/sti_test.rb
friendly_id-4.0.0.beta14 test/sti_test.rb
friendly_id-4.0.0.beta13 test/sti_test.rb
friendly_id-4.0.0.beta12 test/sti_test.rb
friendly_id-4.0.0.beta11 test/sti_test.rb
friendly_id-4.0.0.beta10 test/sti_test.rb
friendly_id-4.0.0.beta8 test/sti_test.rb
friendly_id-4.0.0.beta7 test/sti_test.rb
friendly_id4-4.0.0.beta6 test/sti_test.rb