aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-12-06 10:43:07 +0000
committerLouise Crow <louise.crow@gmail.com>2012-12-06 14:15:58 +0000
commit1d4ef88e60bcecc5c413cf3b6e6cb76f4bb6eaa1 (patch)
tree07ec85e8469f5ed2f1ce6ce3ca241ed0be729f5e
parent12b9d57ea9bbe69e5e195a90085b66056f4116a4 (diff)
Rename _get_attachment_text_internal_one_file to get_attachment_text_one_file as it is now an externally-accessed method of the mail handler module.
-rw-r--r--app/models/incoming_message.rb5
-rw-r--r--lib/mail_handler/mail_handler.rb4
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb5
-rw-r--r--spec/models/incoming_message_spec.rb4
4 files changed, 9 insertions, 9 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index e1702689c..868bec910 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -475,7 +475,7 @@ class IncomingMessage < ActiveRecord::Base
rescue Iconv::IllegalSequence
use_charset = source_charset
end
- text = MailHandler._get_attachment_text_internal_one_file(part.content_type, text, use_charset)
+ text = MailHandler.get_attachment_text_one_file(part.content_type, text, use_charset)
end
end
@@ -510,6 +510,7 @@ class IncomingMessage < ActiveRecord::Base
return text
end
+
# Returns part which contains main body text, or nil if there isn't one
def get_main_body_text_part
leaves = self.foi_attachments
@@ -708,7 +709,7 @@ class IncomingMessage < ActiveRecord::Base
text = ''
attachments = self.get_attachments_for_display
for attachment in attachments
- text += MailHandler._get_attachment_text_internal_one_file(attachment.content_type, attachment.body, attachment.charset)
+ text += MailHandler.get_attachment_text_one_file(attachment.content_type, attachment.body, attachment.charset)
end
# Remove any bad characters
text = Iconv.conv('utf-8//IGNORE', 'utf-8', text)
diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb
index 7d80753c2..4b16fd046 100644
--- a/lib/mail_handler/mail_handler.rb
+++ b/lib/mail_handler/mail_handler.rb
@@ -69,7 +69,7 @@ module MailHandler
return content_type
end
- def _get_attachment_text_internal_one_file(content_type, body, charset = 'utf-8')
+ def get_attachment_text_one_file(content_type, body, charset = 'utf-8')
# note re. charset: TMail always tries to convert email bodies
# to UTF8 by default, so normally it should already be that.
text = ''
@@ -164,7 +164,7 @@ module MailHandler
content_type = 'application/octet-stream'
end
- text += _get_attachment_text_internal_one_file(content_type, body)
+ text += get_attachment_text_one_file(content_type, body)
end
end
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index efa89b6e0..3ccccc6bc 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -255,19 +255,18 @@ end
describe "when parsing HTML mail" do
it "should display UTF-8 characters in the plain text version correctly" do
html = "<html><b>foo</b> është"
- plain_text = MailHandler._get_attachment_text_internal_one_file('text/html', html)
+ plain_text = MailHandler.get_attachment_text_one_file('text/html', html)
plain_text.should match(/është/)
end
end
describe "when getting the attachment text" do
-
it "should not raise an error if the expansion of a zip file raises an error" do
mock_entry = mock('ZipFile entry', :file? => true)
mock_entry.stub!(:get_input_stream).and_raise("invalid distance too far back")
Zip::ZipFile.stub!(:open).and_return([mock_entry])
- MailHandler._get_attachment_text_internal_one_file('application/zip', "some string")
+ MailHandler.get_attachment_text_one_file('application/zip', "some string")
end
end
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 3cfb3d5dd..46dc3a32c 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -305,12 +305,12 @@ describe IncomingMessage, " when censoring data" do
orig_pdf = load_file_fixture('tfl.pdf')
pdf = orig_pdf.dup
- orig_text = MailHandler._get_attachment_text_internal_one_file('application/pdf', pdf)
+ orig_text = MailHandler.get_attachment_text_one_file('application/pdf', pdf)
orig_text.should match(/foi@tfl.gov.uk/)
@im.binary_mask_stuff!(pdf, "application/pdf")
- masked_text = MailHandler._get_attachment_text_internal_one_file('application/pdf', pdf)
+ masked_text = MailHandler.get_attachment_text_one_file('application/pdf', pdf)
masked_text.should_not match(/foi@tfl.gov.uk/)
masked_text.should match(/xxx@xxx.xxx.xx/)
config['USE_GHOSTSCRIPT_COMPRESSION'] = previous