aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/contact_mailer/from_admin_message.text.erb1
-rw-r--r--app/views/request/show.html.erb1
-rw-r--r--config/general.yml-example5
-rw-r--r--lib/tasks/temp.rake20
-rw-r--r--spec/models/info_request_spec.rb54
-rw-r--r--spec/models/user_spec.rb17
7 files changed, 70 insertions, 32 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 257acd0fc..306d6ad4a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -106,7 +106,9 @@ class User < ActiveRecord::Base
name.strip!
end
if self.public_banned?
- name = _("{{user_name}} (Account suspended)", :user_name=>name)
+ # Use interpolation to return a string rather than a SafeBuffer so that
+ # gsub can be called on it until we upgrade to Rails 3.2
+ name = "#{_("{{user_name}} (Account suspended)", :user_name=> name)}"
end
name
end
diff --git a/app/views/contact_mailer/from_admin_message.text.erb b/app/views/contact_mailer/from_admin_message.text.erb
index 4169d8d3a..3af759c5d 100644
--- a/app/views/contact_mailer/from_admin_message.text.erb
+++ b/app/views/contact_mailer/from_admin_message.text.erb
@@ -1,2 +1 @@
<%= raw @message %>
-
diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb
index 4b0663f76..1d5b9977f 100644
--- a/app/views/request/show.html.erb
+++ b/app/views/request/show.html.erb
@@ -25,6 +25,7 @@
<div id="left_column">
<h1><%=h(@info_request.title)%></h1>
+
<% if !@info_request.is_external? && @info_request.user.profile_photo %>
<p class="user_photo_on_request">
<img src="<%= get_profile_photo_url(:url_name => @info_request.user.url_name) %>" alt="">
diff --git a/config/general.yml-example b/config/general.yml-example
index 17e1aa552..5e9e677bf 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -172,6 +172,11 @@ VARNISH_HOST: localhost
# Adding a value here will enable Google Analytics on all non-admin pages for non-admin users.
GA_CODE: ''
+# We need to add the WDTK survey variables here, or else the deployment
+# system will cry.
+SURVEY_SECRET: ''
+SURVEY_URL: ''
+
# If you want to override *all* the public body request emails with your own
# email so that request emails that would normally go to the public body
# go to you, then uncomment below and fill in your email.
diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake
index f0085b5e1..fd0dd069f 100644
--- a/lib/tasks/temp.rake
+++ b/lib/tasks/temp.rake
@@ -40,6 +40,26 @@ namespace :temp do
if ! dryrun
FileUtils.rm_rf(request_subdir)
end
+ else
+ Dir.glob(File.join(request_subdir, 'response', '*')) do |response_subdir|
+ incoming_message_id = File.basename(response_subdir)
+ puts "Looking for IncomingMessage with id #{incoming_message_id}" if verbose
+ begin
+ incoming_message = IncomingMessage.find(incoming_message_id)
+ puts "Got IncomingMessage #{incoming_message_id}" if verbose
+ if incoming_message.info_request != info_request
+ puts "Deleting cache at #{response_subdir}: IncomingMessage #{incoming_message_id} has been moved from InfoRequest #{info_request_id}"
+ if ! dryrun
+ FileUtils.rm_rf(response_subdir)
+ end
+ end
+ rescue ActiveRecord::RecordNotFound
+ puts "Deleting cache at #{response_subdir} for deleted IncomingMessage #{incoming_message_id}"
+ if ! dryrun
+ FileUtils.rm_rf(response_subdir)
+ end
+ end
+ end
end
rescue ActiveRecord::RecordNotFound
puts "Deleting cache at #{request_subdir} for deleted InfoRequest #{info_request_id}"
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 3eb88b2bb..b2f0a20fc 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -454,6 +454,33 @@ describe InfoRequest do
end
+ describe 'when an instance is asked if all can view it' do
+
+ before do
+ @info_request = InfoRequest.new
+ end
+
+ it 'should return true if its prominence is normal' do
+ @info_request.prominence = 'normal'
+ @info_request.all_can_view?.should == true
+ end
+
+ it 'should return true if its prominence is backpage' do
+ @info_request.prominence = 'backpage'
+ @info_request.all_can_view?.should == true
+ end
+
+ it 'should return false if its prominence is hidden' do
+ @info_request.prominence = 'hidden'
+ @info_request.all_can_view?.should == false
+ end
+
+ it 'should return false if its prominence is requester_only' do
+ @info_request.prominence = 'requester_only'
+ @info_request.all_can_view?.should == false
+ end
+ end
+
describe 'when applying censor rules' do
before do
@@ -537,32 +564,5 @@ describe InfoRequest do
end
- describe 'when an instance is asked if all can view it' do
-
- before do
- @info_request = InfoRequest.new
- end
-
- it 'should return true if its prominence is normal' do
- @info_request.prominence = 'normal'
- @info_request.all_can_view?.should == true
- end
-
- it 'should return true if its prominence is backpage' do
- @info_request.prominence = 'backpage'
- @info_request.all_can_view?.should == true
- end
-
- it 'should return false if its prominence is hidden' do
- @info_request.prominence = 'hidden'
- @info_request.all_can_view?.should == false
- end
-
- it 'should return false if its prominence is requester_only' do
- @info_request.prominence = 'requester_only'
- @info_request.all_can_view?.should == false
- end
-
- end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 651ba4b65..96c169604 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -27,11 +27,22 @@ describe User, "showing the name" do
@user.name.should == 'Some Name'
end
- it 'should show if user has been banned' do
- @user.ban_text = "Naughty user"
- @user.name.should == 'Some Name (Account suspended)'
+ describe 'if user has been banned' do
+
+ before do
+ @user.ban_text = "Naughty user"
+ end
+
+ it 'should show an "Account suspended" suffix' do
+ @user.name.should == 'Some Name (Account suspended)'
+ end
+
+ it 'should return a string when the user has been banned, not a SafeBuffer' do
+ @user.name.class.should == String
+ end
end
+
end
describe User, " when authenticating" do