aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/info_request.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--spec/controllers/request_controller_spec.rb25
-rw-r--r--spec/models/user_spec.rb13
-rw-r--r--todo.txt7
5 files changed, 49 insertions, 4 deletions
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)
diff --git a/app/models/user.rb b/app/models/user.rb
index 6c426c810..d3af629c3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.36 2008-03-13 11:29:47 francis Exp $
+# $Id: user.rb,v 1.37 2008-03-15 04:19:04 francis Exp $
require 'digest/sha1'
@@ -92,7 +92,7 @@ class User < ActiveRecord::Base
url_name = url_name[0..31]
end
# For request with same name as others, tag on the request numeric id
- while not User.find_by_url_name(url_name, :conditions => ["id <> ?", self.id] ).nil?
+ while not User.find_by_url_name(url_name, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil?
url_name += "_" + self.id.to_s
end
write_attribute(:url_name, url_name)
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index d8a0466ba..faaffb709 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -128,6 +128,31 @@ describe RequestController, "when creating a new request" do
:submitted_new_request => 1
response.should render_template('new')
end
+
+ it "should let you submit another request with the same title" do
+ session[:user_id] = users(:bob_smith_user).id
+
+ post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id,
+ :title => "Why is your quango called Geraldine?"},
+ :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
+ :submitted_new_request => 1
+
+ post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id,
+ :title => "Why is your quango called Geraldine?"},
+ :outgoing_message => { :body => "This is a sensible letter. It is too long to be boring." },
+ :submitted_new_request => 1
+
+ ir_array = InfoRequest.find(:all, :conditions => ["title = ?", "Why is your quango called Geraldine?"], :order => "id")
+ ir_array.size.should == 2
+
+ ir = ir_array[0]
+ ir2 = ir_array[1]
+
+ ir.url_title.should_not == ir2.url_title
+
+ response.should redirect_to(:controller => 'request', :action => 'show', :url_title => ir2.url_title)
+ end
+
end
describe RequestController, "when viewing an individual response" do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 11e906b6b..69295bf72 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -38,6 +38,7 @@ end
describe User, " when saving" do
before do
@user = User.new
+ @user2 = User.new
end
it "should not save without setting some parameters" do
@@ -64,5 +65,17 @@ describe User, " when saving" do
@user.email = "reasonable@localhost"
@user.save!
end
+
+ it "should let you make two users with same name" do
+ @user.name = "Mr. Flobble"
+ @user.password = "insecurepassword"
+ @user.email = "flobble@localhost"
+ @user.save!
+
+ @user2.name = "Mr. Flobble"
+ @user2.password = "insecurepassword"
+ @user2.email = "flobble2@localhost"
+ @user2.save!
+ end
end
diff --git a/todo.txt b/todo.txt
index 222be8578..ff0cedeb6 100644
--- a/todo.txt
+++ b/todo.txt
@@ -53,6 +53,9 @@ Search and replace text "FOI" and "Freedom of Information" out the way more
- but put it in the title tag
"public body" --> "public authority"?
+download.bin knackered in this one
+http://www.whatdotheyknow.com/request/contracts_or_options_with_kimber
+
Adam's woes:
http://foi.mysociety.org/request/18/response/31
- No doubt leaks email address via download.bin :(
@@ -181,6 +184,10 @@ http://community.foe.co.uk/tools/right_to_know/faq.html#why_specify
Add geographical location to council import
+Quoting fixing TODO:
+ http://www.whatdotheyknow.com/request/64/response/102
+ http://www.whatdotheyknow.com/request/55/response/96
+
Sources of public bodies
========================