Sha256: e8151a09a37f9191a9bbd38f4e864a667e3d6e90ad6796faf8759c12ffc3045a

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

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

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
friendly_id-5.4.1 test/finders_test.rb
friendly_id-5.4.0 test/finders_test.rb