Sha256: 777c24680707133afe6f3a3bb6333744b8b5dfc0c9a30f2b71984ed8ea9f3826

Contents?: true

Size: 767 Bytes

Versions: 45

Compression:

Stored size: 767 Bytes

Contents

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

require "ancestry"

ActiveRecord::Migration.create_table("things") do |t|
  t.string  :name
  t.string  :slug
  t.string :ancestry
end
ActiveRecord::Migration.add_index :things, :ancestry

class Thing < ActiveRecord::Base
  extend FriendlyId
  friendly_id do |config|
    config.use :slugged
    config.use :scoped
    config.base  = :name
    config.scope = :ancestry
  end
  has_ancestry
end

class AncestryTest < MiniTest::Unit::TestCase
  include FriendlyId::Test

  test "should sequence slugs when scoped by ancestry" do
    3.times.inject([]) do |memo, _|
      memo << Thing.create!(:name => "a", :parent => memo.last)
    end.each do |thing|
      assert_equal "a", thing.friendly_id
    end
  end
end

Version data entries

45 entries across 40 versions & 4 rubygems

Version Path
friendly_id-4.0.0.beta14 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.0.beta13 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.0.beta12 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.0.beta11 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.0.beta10 test/compatibility/ancestry/ancestry_test.rb