Sha256: 2ca9d7b6b27ff5e4b889ecf13daec163e24fb47719664ee6241302a06915b558

Contents?: true

Size: 692 Bytes

Versions: 10

Compression:

Stored size: 692 Bytes

Contents

require "helper"

class JournalistWithFriendlyFinders < ActiveRecord::Base
  self.table_name = 'journalists'
  extend FriendlyId
  scope :existing, -> {where('1 = 1')}
  friendly_id :name, use: [:slugged, :finders]
end

class Finders < TestCaseClass

  include FriendlyId::Test

  def model_class
    JournalistWithFriendlyFinders
  end

  test 'should find records with finders as class methods' do
    with_instance_of(model_class) do |record|
      assert model_class.find(record.friendly_id)
    end
  end

  test 'should find records with finders on relations' do
    with_instance_of(model_class) do |record|
      assert model_class.existing.find(record.friendly_id)
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
friendly_id-5.4.2 test/finders_test.rb
friendly_id-5.3.0 test/finders_test.rb
friendly_id-5.2.5 test/finders_test.rb
friendly_id-5.2.4 test/finders_test.rb
friendly_id-5.2.3 test/finders_test.rb
friendly_id-5.2.2 test/finders_test.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/friendly_id-5.2.1/test/finders_test.rb
friendly_id-5.2.1 test/finders_test.rb
friendly_id-5.2.0 test/finders_test.rb
friendly_id-5.2.0.beta.1 test/finders_test.rb