diff options
-rw-r--r-- | app/models/foi_attachment.rb | 2 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 1 | ||||
-rw-r--r-- | app/views/request/_request_listing_via_event.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 1 | ||||
-rw-r--r-- | config/general.yml-example | 5 | ||||
-rw-r--r-- | lib/tasks/temp.rake | 20 | ||||
-rw-r--r-- | spec/models/foi_attachment_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 54 |
9 files changed, 75 insertions, 30 deletions
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 2f8a9ab04..723bc4abb 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -219,7 +219,7 @@ class FoiAttachment < ActiveRecord::Base def ensure_filename! - if self.filename.nil? + if self.filename.blank? calc_ext = AlaveteliFileTypes.mimetype_to_extension(self.content_type) if !calc_ext calc_ext = "bin" diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index a02d2456a..339a7a3e2 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -284,6 +284,7 @@ class IncomingMessage < ActiveRecord::Base # Lotus notes quoting yeuch! def remove_lotus_quoting(text, replacement = "FOLDED_QUOTED_SECTION") text = text.dup + return text if self.info_request.user_name.nil? name = Regexp.escape(self.info_request.user_name) # To end of message sections diff --git a/app/views/request/_request_listing_via_event.rhtml b/app/views/request/_request_listing_via_event.rhtml index ee1cc079a..2ba9613e5 100644 --- a/app/views/request/_request_listing_via_event.rhtml +++ b/app/views/request/_request_listing_via_event.rhtml @@ -25,7 +25,7 @@ end %> <%=event.display_status %> <%= _('by {{public_body_name}} to {{info_request_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:date=>simple_date(event.created_at )) %> <% elsif event.event_type == 'comment' %> - <%= _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>user_link_absolute(info_request.user),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at)) %> + <%= _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.',:public_body_name=>public_body_link_absolute(info_request.public_body),:info_request_user=>request_user_link_absolute(info_request),:event_comment_user=>user_link_absolute(event.comment.user),:date=>simple_date(event.created_at)) %> <% else %> <%# Events of other types will not be indexed: see InfoRequestEvent#indexed_by_search? However, it can happen that we see other types of event transiently here in the period diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index 7aff1aeab..e3ddf3b1b 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -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 bfe289541..30221bac4 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -180,6 +180,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 e49a84ecb..e50ee2cb8 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/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb index 9d44957e4..537a3363c 100644 --- a/spec/models/foi_attachment_spec.rb +++ b/spec/models/foi_attachment_spec.rb @@ -30,6 +30,17 @@ describe FoiAttachment, " when calculating due date" do main.delete_cached_file! main = im.get_main_body_text_part main.body.should == orig_body - + end end + +describe FoiAttachment, "when ensuring a filename is present" do + + it 'should create a filename for an instance with a blank filename' do + attachment = FoiAttachment.new + attachment.filename = '' + attachment.ensure_filename! + attachment.filename.should == 'attachment.bin' + end + +end diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 6fc0ff3cc..f53a5856a 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -148,6 +148,13 @@ describe IncomingMessage, " folding quoted parts of emails" do @incoming_message.remove_lotus_quoting(text).should match(/FOLDED_QUOTED_SECTION/) end + it 'should not error when trying to fold lotus notes quoted parts on a request with no user_name' do + text = "hello" + @incoming_message = IncomingMessage.new() + @incoming_message.stub_chain(:info_request, :user_name).and_return(nil) + @incoming_message.remove_lotus_quoting(text).should == 'hello' + end + it "cope with [ in user names properly" do @incoming_message = IncomingMessage.new() @incoming_message.stub_chain(:info_request, :user_name).and_return("Sir [ Bobble") diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 544852f91..4112a2baa 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 |