Skip to content

Commit

Permalink
Add test for numeric slug
Browse files Browse the repository at this point in the history
  • Loading branch information
sethbaugh authored and parndt committed Jun 30, 2018
1 parent a06bee8 commit e8186c6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/numeric_slug_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'helper'

class NumericSlugTest < TestCaseClass
include FriendlyId::Test
include FriendlyId::Test::Shared::Core

def model_class
Article
end

test "should generate numeric slugs" do
transaction do
record = model_class.create! :name => "123"
assert_equal "123", record.slug
end
end

test "should find by numeric slug" do
transaction do
record = model_class.create! :name => "123"
assert_equal model_class.friendly.find("123").id, record.id
end
end

test "should exist? by numeric slug" do
transaction do
record = model_class.create! :name => "123"
assert model_class.friendly.exists?("123")
end
end
end

0 comments on commit e8186c6

Please sign in to comment.