<< strikes again

This commit is contained in:
joshua stein 2012-07-18 13:15:48 -05:00
parent c945f29040
commit edcee1bddd
2 changed files with 12 additions and 5 deletions

View file

@ -66,8 +66,8 @@ class Story < ActiveRecord::Base
end
def self.find_recent_similar_by_url(url)
urls = [ url ]
urls2 = [ url ]
urls = [ url.to_s ]
urls2 = [ url.to_s ]
# https
urls.each do |u|
@ -79,7 +79,7 @@ class Story < ActiveRecord::Base
# trailing slash
urls.each do |u|
urls2.push u.gsub(/\/+\z/, "")
urls2.push (u << "/")
urls2.push (u + "/")
end
urls = urls2.clone
@ -91,9 +91,9 @@ class Story < ActiveRecord::Base
urls = urls2.clone
conds = [ "created_at >= ? AND (", (Time.now - 30.days) ]
urls.uniq.each_with_index do |url,x|
urls.uniq.each_with_index do |u,x|
conds[0] << (x == 0 ? "" : " OR ") << "url = ?"
conds.push url
conds.push u
end
conds[0] << ")"

View file

@ -103,4 +103,11 @@ describe Story 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
it "sets the url properly" do
s = Story.make(:title => "blah")
s.url = "https://factorable.net/"
s.valid?
s.url.should == "https://factorable.net/"
end
end