Sha256: 22e250fefff409a0bae94f2d7b6bc2c866db068ef94d9d8a151041401c6aa211
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# encoding: utf-8 require File.dirname(__FILE__) + '/test_helper' class CustomSlugNormalizerTest < Test::Unit::TestCase context "A slugged model using a custom slug generator" do setup do Thing.friendly_id_options = FriendlyId::DEFAULT_OPTIONS.merge(:method => :name, :use_slug => true) end teardown do Thing.delete_all Slug.delete_all end should "invoke the block code" do thing = Thing.create!(:name => "test") assert_equal "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", thing.friendly_id end should "respect the max_length option" do Thing.friendly_id_options = Thing.friendly_id_options.merge(:max_length => 10) thing = Thing.create!(:name => "test") assert_equal "a94a8fe5cc", thing.friendly_id end should "respect the reserved option" do Thing.friendly_id_options = Thing.friendly_id_options.merge(:reserved => ["a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"]) assert_raises FriendlyId::SlugGenerationError do Thing.create!(:name => "test") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
friendly_id-2.2.5 | test/custom_slug_normalizer_test.rb |
friendly_id-2.2.4 | test/custom_slug_normalizer_test.rb |
friendly_id-2.2.3 | test/custom_slug_normalizer_test.rb |