From 0a423eae84d6c2b123a50d2c7e8195a873aa224a Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 15 Mar 2008 04:19:03 +0000 Subject: Add tests for broken case of saving info request or user when there is existing one with same title/name. Fix the bug, which was in function that makes url_title/url_name. --- app/models/info_request.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 2539e4d60..4d1d577dc 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.65 2008-03-14 10:03:20 francis Exp $ +# $Id: info_request.rb,v 1.66 2008-03-15 04:19:04 francis Exp $ require 'digest/sha1' @@ -145,7 +145,7 @@ public url_title = url_title[0..31] end # For request with same name as others, tag on the request numeric id - while not InfoRequest.find_by_url_title(url_title, :conditions => ["id <> ?", self.id] ).nil? + while not InfoRequest.find_by_url_title(url_title, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil? url_title += "_" + self.id.to_s end write_attribute(:url_title, url_title) -- cgit v1.2.3