diff options
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 1 | ||||
-rw-r--r-- | Rakefile | 1 | ||||
-rw-r--r-- | app/models/foi_attachment.rb | 2 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 1 | ||||
-rw-r--r-- | app/models/public_body.rb | 2 | ||||
-rw-r--r-- | app/views/request/_request_listing_via_event.rhtml | 2 | ||||
-rw-r--r-- | lib/tasks/rspec.rake | 5 | ||||
-rw-r--r-- | spec/models/foi_attachment_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 7 |
10 files changed, 27 insertions, 8 deletions
@@ -31,7 +31,6 @@ gem 'recaptcha', '~> 0.3.1', :require => 'recaptcha/rails' gem 'rmagick', :require => 'RMagick' gem 'routing-filter', '~> 0.2.4' gem 'rake', '0.9.2.2' -gem 'rspec', '~> 1.3.2' gem 'ruby-msg', '~> 1.5.0' gem 'vpim' gem 'will_paginate', '~> 2.3.11' diff --git a/Gemfile.lock b/Gemfile.lock index 903562017..a9ab14940 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,7 +177,6 @@ DEPENDENCIES recaptcha (~> 0.3.1) rmagick routing-filter (~> 0.2.4) - rspec (~> 1.3.2) rspec-rails (~> 1.3.4) ruby-debug ruby-debug19 @@ -9,4 +9,3 @@ require 'rdoc/task' require 'tasks/rails' -Dir[File.join(File.dirname(__FILE__),'commonlib','rblib','tests','*.rake')].each { |file| load(file) } 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/models/public_body.rb b/app/models/public_body.rb index 57fe27767..96f7733ed 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -520,6 +520,8 @@ class PublicBody < ActiveRecord::Base 'Version', ] public_bodies.each do |public_body| + # Skip bodies we use only for site admin + next if public_body.has_tag?('site_administration') csv << [ public_body.name, public_body.short_name, 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/lib/tasks/rspec.rake b/lib/tasks/rspec.rake index 1eee74aee..d4fd4a9ff 100644 --- a/lib/tasks/rspec.rake +++ b/lib/tasks/rspec.rake @@ -23,6 +23,9 @@ rescue MissingSourceFile module Spec module Rake class SpecTask + if defined?(::Rake::DSL) + include ::Rake::DSL + end def initialize(name) task name do # if rspec-rails is a configured gem, this will output helpful material and exit ... @@ -52,8 +55,6 @@ end task :default => :spec task :stats => "spec:statsetup" -# XXX commonlib tests are not Ruby 1.9 compatible -#task :spec => ['spec:commonlib'] task :test => ['spec'] task :cruise => ['spec'] 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") |