aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2009-10-01 01:43:36 +0000
committerfrancis <francis>2009-10-01 01:43:36 +0000
commit705ebd5cb64908a336bab16b190d36ff0456fded (patch)
tree670eabfc0fccda88db37a590820ec3f1b85f2581
parent5fb1cd5857040d4859237013123aa4aec250250a (diff)
Let some users leave requests undescribed.
-rw-r--r--app/controllers/request_controller.rb4
-rw-r--r--app/models/user.rb11
-rw-r--r--spec/controllers/request_controller_spec.rb11
3 files changed, 23 insertions, 3 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 4843727e2..9cad01edf 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.185 2009-09-23 22:22:20 francis Exp $
+# $Id: request_controller.rb,v 1.186 2009-10-01 01:43:38 francis Exp $
class RequestController < ApplicationController
@@ -126,7 +126,7 @@ class RequestController < ApplicationController
# margin of 1 undescribed so it isn't too annoying - the function
# get_undescribed_requests also allows one day since the response
# arrived.
- if !@user.nil? && params[:submitted_new_request].nil?
+ if !@user.nil? && params[:submitted_new_request].nil? && !@user.can_leave_requests_undescribed?
@undescribed_requests = @user.get_undescribed_requests
if params[:public_body_id].nil?
redirect_to frontpage_url
diff --git a/app/models/user.rb b/app/models/user.rb
index 8690f045f..e0698a47f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -24,7 +24,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.105 2009-09-20 10:25:13 francis Exp $
+# $Id: user.rb,v 1.106 2009-10-01 01:43:36 francis Exp $
require 'digest/sha1'
@@ -218,6 +218,15 @@ class User < ActiveRecord::Base
)
end
+ # Can the user make new requests, without having to describe state of (most) existing ones?
+ def can_leave_requests_undescribed?
+ # XXX should be flag in database really
+ if self.url_name == "heather_brooke" || self.url_name == "heather_brooke_2"
+ return true
+ end
+ return false
+ end
+
# Does the user magically gain powers as if they owned every request?
# e.g. Can classify it
def owns_every_request?
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index c84673b23..917826d45 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -376,6 +376,7 @@ describe RequestController, "when making a new request" do
before do
@user = mock_model(User, :id => 3481, :name => 'Testy')
@user.stub!(:get_undescribed_requests).and_return([])
+ @user.stub!(:can_leave_requests_undescribed?).and_return(false)
@user.stub!(:can_file_requests?).and_return(true)
User.stub!(:find).and_return(@user)
@@ -385,6 +386,7 @@ describe RequestController, "when making a new request" do
it "should allow you to have one undescribed request" do
@user.stub!(:get_undescribed_requests).and_return([ 1 ])
+ @user.stub!(:can_leave_requests_undescribed?).and_return(false)
session[:user_id] = @user.id
get :new, :public_body_id => @body.id
response.should render_template('new')
@@ -392,11 +394,20 @@ describe RequestController, "when making a new request" do
it "should fail if more than one request undescribed" do
@user.stub!(:get_undescribed_requests).and_return([ 1, 2 ])
+ @user.stub!(:can_leave_requests_undescribed?).and_return(false)
session[:user_id] = @user.id
get :new, :public_body_id => @body.id
response.should render_template('new_please_describe')
end
+ it "should allow you if more than one request undescribed but are allowed to leave requests undescribed" do
+ @user.stub!(:get_undescribed_requests).and_return([ 1, 2 ])
+ @user.stub!(:can_leave_requests_undescribed?).and_return(true)
+ session[:user_id] = @user.id
+ get :new, :public_body_id => @body.id
+ response.should render_template('new')
+ end
+
it "should fail if user is banned" do
@user.stub!(:can_file_requests?).and_return(false)
@user.should_receive(:can_fail_html).and_return('FAIL!')