Sha256: 5422f889a5e1b8f4aaf82dc14a55b39a3d5eb7d7699cb87f812abc8d72918256

Contents?: true

Size: 1.05 KB

Versions: 28

Compression:

Stored size: 1.05 KB

Contents

require "helper"

class Book < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name
end

class Author < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name
  has_many :books
end

class CoreTest < MiniTest::Unit::TestCase

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

  def model_class
    Author
  end

  test "models don't use friendly_id by default" do
    assert !Class.new(ActiveRecord::Base) {
      self.abstract_class = true
    }.respond_to?(:friendly_id)
  end

  test "model classes should have a friendly id config" do
    assert model_class.friendly_id(:name).friendly_id_config
  end

  test "instances should have a friendly id" do
    with_instance_of(model_class) {|record| assert record.friendly_id}
  end

  test "instances can be marshaled when a relationship is used" do
    transaction do
      author = Author.create :name => 'Philip'
      author.books.create :name => 'my book'
      begin
        assert Marshal.load(Marshal.dump(author))
      rescue TypeError => e
        flunk(e.to_s)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
friendly_id-5.0.4 test/core_test.rb
friendly_id-5.0.3 test/core_test.rb
friendly_id-5.0.2 test/core_test.rb
friendly_id-5.0.1 test/core_test.rb
friendly_id-5.0.0 test/core_test.rb
friendly_id-5.0.0.rc3 test/core_test.rb
friendly_id-5.0.0.rc2 test/core_test.rb
mil_friendly_id-4.0.9.9 test/core_test.rb
friendly_id-5.0.0.rc1 test/core_test.rb
friendly_id-5.0.0.beta4 test/core_test.rb
friendly_id-5.0.0.beta3 test/core_test.rb
friendly_id-4.0.10.1 test/core_test.rb
friendly_id-5.0.0.beta2 test/core_test.rb
friendly_id-5.0.0.beta1 test/core_test.rb
friendly_id-4.0.10 test/core_test.rb
friendly_id-5.0.0.alpha.1 test/core_test.rb
mil_friendly_id-4.0.9.8 test/core_test.rb
geothird_friendly_id-4.0.9.8 test/core_test.rb
geothird_friendly_id-4.0.9.7 test/core_test.rb
geothird_friendly_id-4.0.9.6 test/core_test.rb