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
mil_friendly_id-4.0.9.9 test/compatibility/ancestry/ancestry_test.rb
friendly_id-5.0.0.beta4 test/compatibility/ancestry/ancestry_test.rb
friendly_id-5.0.0.beta3 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.10.1 test/compatibility/ancestry/ancestry_test.rb
friendly_id-5.0.0.beta2 test/compatibility/ancestry/ancestry_test.rb
friendly_id-5.0.0.beta1 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.10 test/compatibility/ancestry/ancestry_test.rb
friendly_id-5.0.0.alpha.1 test/compatibility/ancestry/ancestry_test.rb
mil_friendly_id-4.0.9.8 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.8 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.7 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.6 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.5 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.4 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.3 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.2 test/compatibility/ancestry/ancestry_test.rb
geothird_friendly_id-4.0.9.1 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.1.0.beta.1 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.9 test/compatibility/ancestry/ancestry_test.rb
friendly_id-4.0.8 test/compatibility/ancestry/ancestry_test.rb