remove leading and trailing underscores from title_as_url
This commit is contained in:
parent
4a221aa2d3
commit
6258cb7f75
|
@ -180,7 +180,7 @@ class Story < ActiveRecord::Base
|
||||||
while u.match(/__/)
|
while u.match(/__/)
|
||||||
u.gsub!("__", "_")
|
u.gsub!("__", "_")
|
||||||
end
|
end
|
||||||
u
|
u.gsub(/^_+/, "").gsub(/_+$/, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
def url_or_comments_url(root_url = "/")
|
def url_or_comments_url(root_url = "/")
|
||||||
|
|
|
@ -93,4 +93,9 @@ describe Story do
|
||||||
"spec/fixtures/story_pages/2.html")
|
"spec/fixtures/story_pages/2.html")
|
||||||
s.fetched_title.should == "Google"
|
s.fetched_title.should == "Google"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "has an underscored url from its title" do
|
||||||
|
s = Story.make(:title => "The One-second War (What Time Will You Die?) ")
|
||||||
|
s.title_as_url.should == "the_one-second_war_what_time_will_you_die"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue