aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--README.md2
-rw-r--r--app/controllers/admin_public_body_controller.rb2
-rw-r--r--app/mailers/request_mailer.rb3
-rw-r--r--app/models/public_body.rb23
-rw-r--r--app/views/comment/_single_comment.html.erb4
-rw-r--r--app/views/general/_stylesheet_includes.html.erb2
-rw-r--r--app/views/layouts/no_chrome.html.erb1
-rw-r--r--config/application.rb1
-rw-r--r--lib/mail_handler/mail_handler.rb2
-rw-r--r--lib/tasks/import.rake12
-rw-r--r--spec/fixtures/files/document-pdf.email110
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb6
-rw-r--r--spec/mailers/request_mailer_spec.rb21
-rw-r--r--spec/models/public_body_spec.rb14
16 files changed, 186 insertions, 22 deletions
diff --git a/Gemfile b/Gemfile
index 7e33a5f12..824b4f1f7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -77,7 +77,6 @@ end
group :develop do
gem 'ruby-debug', :platforms => :ruby_18
gem 'debugger', :platforms => :ruby_19
- gem 'byebug', :platforms => :ruby_20
gem 'annotate'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index c5c1fa3b4..62258c0c6 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -51,9 +51,6 @@ GEM
bootstrap-sass (2.3.1.2)
sass (~> 3.2)
builder (3.0.4)
- byebug (2.3.1)
- columnize (~> 0.3.6)
- debugger-linecache (~> 1.2.0)
capistrano (2.15.4)
highline
net-scp (>= 1.0.0)
@@ -281,7 +278,6 @@ DEPENDENCIES
acts_as_versioned!
annotate
bootstrap-sass
- byebug
capistrano
charlock_holmes
coffee-rails (~> 3.2.1)
diff --git a/README.md b/README.md
index 8dc3125a1..74d06b1f4 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ drop a line to hello@alaveteli.org to let us know that you're using Alaveteli.
Some documentation can be found in the
[`doc/` folder](https://github.com/mysociety/alaveteli/tree/master/doc).
-There's background information and a more documentation on
+There's background information and more documentation on
[our wiki](https://github.com/mysociety/alaveteli/wiki/Home/), and lots
of useful information (including a blog) on
[the project website](http://alaveteli.org)
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index e0da234b0..88e275960 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -143,6 +143,8 @@ class AdminPublicBodyController < AdminController
@errors = ""
if request.post?
dry_run_only = (params['commit'] == 'Upload' ? false : true)
+ # (FIXME: both of these cases could now be changed to use
+ # PublicBody.import_csv_from_file.)
# Read file from params
if params[:csv_file]
csv_contents = params[:csv_file].read
diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb
index c8a19afa8..af1a75df9 100644
--- a/app/mailers/request_mailer.rb
+++ b/app/mailers/request_mailer.rb
@@ -19,7 +19,8 @@ class RequestMailer < ApplicationMailer
end
mail(:from => from_user.name_and_email,
- :to => info_request.incoming_name_and_email)
+ :to => info_request.incoming_name_and_email,
+ :subject => info_request.email_subject_followup)
end
# Used when a response is uploaded using the API
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 8e474c797..eb0905f9e 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -369,10 +369,24 @@ class PublicBody < ActiveRecord::Base
class ImportCSVDryRun < StandardError
end
- # Import from CSV. Just tests things and returns messages if dry_run is true.
- # Returns an array of [array of errors, array of notes]. If there are errors,
- # always rolls back (as with dry_run).
+ # Import from a string in CSV format.
+ # Just tests things and returns messages if dry_run is true.
+ # Returns an array of [array of errors, array of notes]. If there
+ # are errors, always rolls back (as with dry_run).
def self.import_csv(csv, tag, tag_behaviour, dry_run, editor, available_locales = [])
+ tmp_csv = nil
+ Tempfile.open('alaveteli') do |f|
+ f.write csv
+ tmp_csv = f
+ end
+ PublicBody.import_csv_from_file(tmp_csv.path, tag, tag_behaviour, dry_run, editor, available_locales)
+ end
+
+ # Import from a CSV file.
+ # Just tests things and returns messages if dry_run is true.
+ # Returns an array of [array of errors, array of notes]. If there
+ # are errors, always rolls back (as with dry_run).
+ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = [])
errors = []
notes = []
available_locales = [I18n.default_locale] if available_locales.empty?
@@ -398,7 +412,8 @@ class PublicBody < ActiveRecord::Base
set_of_importing = Set.new()
field_names = { 'name'=>1, 'request_email'=>2 } # Default values in case no field list is given
line = 0
- CSV.parse(csv) do |row|
+
+ CSV.foreach(csv_filename) do |row|
line = line + 1
# Parse the first line as a field list if it starts with '#'
diff --git a/app/views/comment/_single_comment.html.erb b/app/views/comment/_single_comment.html.erb
index d2edc8dbe..a6d234b34 100644
--- a/app/views/comment/_single_comment.html.erb
+++ b/app/views/comment/_single_comment.html.erb
@@ -17,10 +17,10 @@
</div>
<p class="event_actions">
<% if !comment.id.nil? %>
- <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %>
<% if !@user.nil? && @user.admin_page_links? %>
- | <%= link_to "Admin", admin_request_edit_comment_path(comment) %>
+ <%= link_to "Admin", admin_request_edit_comment_path(comment) %> |
<% end %>
+ <%= link_to "Link to this", comment_path(comment), :class => "link_to_this" %>
<!-- | <%= link_to _('Report abuse'), comment_path(comment) %> -->
<% end %>
</p>
diff --git a/app/views/general/_stylesheet_includes.html.erb b/app/views/general/_stylesheet_includes.html.erb
index b3f32054c..7a1648efd 100644
--- a/app/views/general/_stylesheet_includes.html.erb
+++ b/app/views/general/_stylesheet_includes.html.erb
@@ -17,6 +17,6 @@
<%= stylesheet_link_tag 'ie7.css' %>
<![endif]-->
<% if AlaveteliConfiguration::force_registration_on_new_request %>
- <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.pack.js', :rel => "stylesheet" %>
+ <%= stylesheet_link_tag 'jquery.fancybox-1.3.4.css', :rel => "stylesheet" %>
<% end %>
<% end %>
diff --git a/app/views/layouts/no_chrome.html.erb b/app/views/layouts/no_chrome.html.erb
index 589e1bb76..e613b8ca2 100644
--- a/app/views/layouts/no_chrome.html.erb
+++ b/app/views/layouts/no_chrome.html.erb
@@ -14,7 +14,6 @@
<%= stylesheet_link_tag 'application', :title => "Main", :rel => "stylesheet" %>
<%= stylesheet_link_tag 'fonts', :rel => "stylesheet" %>
- <%= stylesheet_link_tag 'theme', :rel => "stylesheet" %>
<!--[if LT IE 7]>
<%= stylesheet_link_tag 'ie6', :rel => "stylesheet" %>
<![endif]-->
diff --git a/config/application.rb b/config/application.rb
index dba3a0c57..3c749a531 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -94,6 +94,7 @@ module Alaveteli
# ... while these are individual files that can't easily be
# grouped:
config.assets.precompile += ['jquery.fancybox-1.3.4.pack.js',
+ 'jquery.fancybox-1.3.4.css',
'jquery.Jcrop.css',
'excanvas.min.js',
'fonts.css',
diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb
index 918f91180..53033d440 100644
--- a/lib/mail_handler/mail_handler.rb
+++ b/lib/mail_handler/mail_handler.rb
@@ -59,7 +59,7 @@ module MailHandler
end
# e.g. http://www.whatdotheyknow.com/request/copy_of_current_swessex_scr_opt#incoming-9928
- if content_type == 'application/acrobat'
+ if content_type == 'application/acrobat' or content_type == 'document/pdf'
content_type = 'application/pdf'
end
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index 0e8397fde..c8183c745 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -54,12 +54,12 @@ namespace :import do
STDERR.puts "Now importing the public bodies..."
# Now it's (probably) safe to try to import:
- errors, notes = PublicBody.import_csv(tmp_csv.path,
- tag='',
- tag_behaviour='replace',
- dryrun,
- editor="#{ENV['USER']} (Unix user)",
- I18n.available_locales) do |row_number, fields|
+ errors, notes = PublicBody.import_csv_from_file(tmp_csv.path,
+ tag='',
+ tag_behaviour='replace',
+ dryrun,
+ editor="#{ENV['USER']} (Unix user)",
+ I18n.available_locales) do |row_number, fields|
percent_complete = (100 * row_number.to_f / number_of_rows).to_i
STDERR.print "#{row_number} out of #{number_of_rows} "
STDERR.puts "(#{percent_complete}% complete)"
diff --git a/spec/fixtures/files/document-pdf.email b/spec/fixtures/files/document-pdf.email
new file mode 100644
index 000000000..f4fc6f0fe
--- /dev/null
+++ b/spec/fixtures/files/document-pdf.email
@@ -0,0 +1,110 @@
+From authority@example.org Tue Dec 3 11:13:02 2013
+Return-path: <authority@example.org>
+Envelope-to: requester@example.org
+Delivery-date: Tue, 03 Dec 2013 11:13:00 +0000
+From: Test Authority <authority@example.org>
+To: requester@example.org
+Subject: testing a PDF attachment with the wrong content-type
+Date: Tue, 03 Dec 2013 11:12:45 +0000
+Message-ID: <87li09xuasdfasdfpoija@blahblah>
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="=-=-="
+
+--=-=-=
+Content-Type: text/plain
+
+Here's a PDF attachement which has a document/pdf content-type,
+when it really should be application/pdf.
+
+
+--=-=-=
+Content-Type: application/pdf
+Content-Disposition: attachment; filename=tiny-example.pdf
+Content-Transfer-Encoding: base64
+Content-Description: a very small example PDF
+
+JVBERi0xLjUKJbXtrvsKMyAwIG9iago8PCAvTGVuZ3RoIDQgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRl
+RGVjb2RlCj4+CnN0cmVhbQp4nCvkMlAAwaJ0Bf1EA4X0Yi6nEC5DA1M9IwNLYzNjsBwS18hIz9TI
+0tBSwdzIQs/Y3MLAzEQhJJdLP03XQBeoUCEkjStawyM1JydfUTM2xIvLNYQrkAsAJG8VmQplbmRz
+dHJlYW0KZW5kb2JqCjQgMCBvYmoKICAgOTIKZW5kb2JqCjIgMCBvYmoKPDwKICAgL0V4dEdTdGF0
+ZSA8PAogICAgICAvYTAgPDwgL0NBIDEgL2NhIDEgPj4KICAgPj4KICAgL0ZvbnQgPDwKICAgICAg
+L2YtMC0wIDUgMCBSCiAgID4+Cj4+CmVuZG9iago2IDAgb2JqCjw8IC9UeXBlIC9QYWdlCiAgIC9Q
+YXJlbnQgMSAwI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BSCj4+CmVuZG9iagp4cmVmCjAgMTQKMDAwMDAwMDAwMCA2
+NTUzNSBmIAowMDAwMDA0MDYyIDAwMDAwIG4gCjAwMDAwMDAyMDUgMDAwMDAgbiAKMDAwMDAwMDAx
+NSAwMDAwMCBuIAowMDAwMDAwMTg0IDAwMDAwIG4gCjAwMDAwMDM2NzkgMDAwMDAgbiAKMDAwMDAw
+MDMxNCAwMDAwMCBuIAowMDAwMDAwNTQyIDAwMDAwIG4gCjAwMDAwMDMwMzggMDAwMDAgbiAKMDAw
+MDAwMzA2MSAwMDAwMCBuIAowMDAwMDAzMzg1IDAwMDAwIG4gCjAwMDAwMDM0MDggMDAwMDAgbiAK
+MDAwMDAwNDEyNyAwMDAwMCBuIAowMDAwMDA0MjU3IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUg
+MTQKICAgL1Jvb3QgMTMgMCBSCiAgIC9JbmZvIDEyIDAgUgo+PgpzdGFydHhyZWYKNDMxMAolJUVP
+Rgo=
+--=-=-=--
+
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index bc027eaec..49a65dade 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -409,6 +409,12 @@ describe 'when getting attachment attributes' do
attributes[1][:body].length.should == 7769
end
+ it 'should treat a document/pdf attachment as application/pdf' do
+ mail = get_fixture_mail('document-pdf.email')
+ attributes = MailHandler.get_attachment_attributes(mail)
+ attributes[1][:content_type].should == "application/pdf"
+ end
+
it 'should produce a consistent set of url_part_numbers, content_types, within_rfc822_subjects
and filenames from an example mail with lots of attachments' do
mail = get_fixture_mail('many-attachments-date-header.email')
diff --git a/spec/mailers/request_mailer_spec.rb b/spec/mailers/request_mailer_spec.rb
index 4e0765921..516d13127 100644
--- a/spec/mailers/request_mailer_spec.rb
+++ b/spec/mailers/request_mailer_spec.rb
@@ -332,6 +332,27 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla
end
+describe RequestMailer, 'when generating a fake response for an upload' do
+
+ before do
+ @foi_officer = mock_model(User, :name_and_email => "FOI officer's name and email")
+ @request_user = mock_model(User)
+ @public_body = mock_model(PublicBody, :name => 'Test public body')
+ @info_request = mock_model(InfoRequest, :user => @request_user,
+ :email_subject_followup => 'Re: Freedom of Information - Test request',
+ :incoming_name_and_email => 'Someone <someone@example.org>')
+ end
+
+ it 'should should generate a "fake response" email with a reasonable subject line' do
+ fake_email = RequestMailer.fake_response(@info_request,
+ @foi_officer,
+ "The body of the email...",
+ "blah.txt",
+ "The content of blah.txt")
+ fake_email.subject.should == "Re: Freedom of Information - Test request"
+ end
+
+end
describe RequestMailer, 'when sending a new response email' do
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 23842ccff..d1e2e233d 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -473,6 +473,20 @@ describe PublicBody, " when loading CSV files" do
PublicBody.count.should == original_count
end
+
+ it "should be able to load CSV from a file as well as a string" do
+ # Essentially the same code is used for import_csv_from_file
+ # as import_csv, so this is just a basic check that
+ # import_csv_from_file can load from a file at all. (It would
+ # be easy to introduce a regression that broke this, because
+ # of the confusing change in behaviour of CSV.parse between
+ # Ruby 1.8 and 1.9.)
+ original_count = PublicBody.count
+ filename = file_fixture_name('fake-authority-type-with-field-names.csv')
+ PublicBody.import_csv_from_file(filename, '', 'replace', false, 'someadmin')
+ PublicBody.count.should == original_count + 3
+ end
+
end
describe PublicBody do