forked from norman/friendly_id
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Norman Clarke
committed
Feb 9, 2009
1 parent
5bb5cf2
commit 8d46285
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Book < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Novel < Book | ||
has_friendly_id :title, :use_slug => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# encoding: utf-8 | ||
|
||
require File.dirname(__FILE__) + '/test_helper' | ||
|
||
class SluggedModelTest < Test::Unit::TestCase | ||
|
||
context "A slugged model using single table inheritance" do | ||
|
||
setup do | ||
Novel.friendly_id_options = FriendlyId::DEFAULT_FRIENDLY_ID_OPTIONS.merge(:column => :title, :use_slug => true) | ||
Novel.delete_all | ||
Slug.delete_all | ||
@novel = Novel.new :title => "Test novel" | ||
@novel.save! | ||
end | ||
|
||
should "have a slug" do | ||
assert_not_nil @novel.slug | ||
end | ||
|
||
context "found by its friendly id" do | ||
|
||
setup do | ||
@novel = Novel.find(@novel.friendly_id) | ||
end | ||
|
||
should "not indicate that it has a better id" do | ||
assert !@novel.has_better_id? | ||
end | ||
|
||
end | ||
|
||
|
||
context "found by its numeric id" do | ||
|
||
setup do | ||
@novel = Novel.find(@novel.id) | ||
end | ||
|
||
should "indicate that it has a better id" do | ||
assert @novel.has_better_id? | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters