Sha256: 889a72b885f47a9d3df193d61e5d12fcb422abdf1c6af9592e047661d3ed44d9

Contents?: true

Size: 1.23 KB

Versions: 34

Compression:

Stored size: 1.23 KB

Contents

require "helper"

class ConfigurationTest < MiniTest::Unit::TestCase

  include FriendlyId::Test

  def setup
    @model_class = Class.new(ActiveRecord::Base) do
      self.abstract_class = true
    end
  end

  test "should set model class on initialization" do
    config = FriendlyId::Configuration.new @model_class
    assert_equal @model_class, config.model_class
  end

  test "should set options on initialization if present" do
    config = FriendlyId::Configuration.new @model_class, :base => "hello"
    assert_equal "hello", config.base
  end

  test "should raise error if passed unrecognized option" do
    assert_raises NoMethodError do
      FriendlyId::Configuration.new @model_class, :foo => "bar"
    end
  end

  test "#use should accept a name that resolves to a module" do
    refute @model_class < FriendlyId::Slugged
    @model_class.class_eval do
      extend FriendlyId
      friendly_id :hello, :use => :slugged
    end
    assert @model_class < FriendlyId::Slugged
  end

  test "#use should accept a module" do
    my_module = Module.new
    refute @model_class < my_module
    @model_class.class_eval do
      extend FriendlyId
      friendly_id :hello, :use => my_module
    end
    assert @model_class < my_module
  end

end

Version data entries

34 entries across 29 versions & 4 rubygems

Version Path
mil_friendly_id-4.0.9.9 test/configuration_test.rb
friendly_id-5.0.0.beta3 test/configuration_test.rb
friendly_id-4.0.10.1 test/configuration_test.rb
friendly_id-5.0.0.beta2 test/configuration_test.rb
friendly_id-5.0.0.beta1 test/configuration_test.rb
friendly_id-4.0.10 test/configuration_test.rb
friendly_id-5.0.0.alpha.1 test/configuration_test.rb
mil_friendly_id-4.0.9.8 test/configuration_test.rb
geothird_friendly_id-4.0.9.8 test/configuration_test.rb
geothird_friendly_id-4.0.9.7 test/configuration_test.rb
geothird_friendly_id-4.0.9.6 test/configuration_test.rb
geothird_friendly_id-4.0.9.5 test/configuration_test.rb
geothird_friendly_id-4.0.9.4 test/configuration_test.rb
geothird_friendly_id-4.0.9.3 test/configuration_test.rb
geothird_friendly_id-4.0.9.2 test/configuration_test.rb
geothird_friendly_id-4.0.9.1 test/configuration_test.rb
friendly_id-4.1.0.beta.1 test/configuration_test.rb
friendly_id-4.0.9 test/configuration_test.rb
friendly_id-4.0.8 test/configuration_test.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/friendly_id-4.0.6/test/configuration_test.rb