diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-09 21:34:15 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-09 21:34:15 +0000 |
commit | 4fe1a1d68234197d5303ad7323dd91636b84db14 (patch) | |
tree | e66779ac77cd3ab8d9b39f6957e7e06fa2a4ae4e /spec/models | |
parent | bb87d842ec3559483a2c0132dbc0c216e0cb597e (diff) | |
parent | 19a0a2fedf68a256084d4dcfd70b9cb9377b9a09 (diff) |
Merge branch 'release/0.5' of github.com:sebbacon/alaveteli into release/0.5
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/foi_attachment_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb new file mode 100644 index 000000000..d8166dddc --- /dev/null +++ b/spec/models/foi_attachment_spec.rb @@ -0,0 +1,36 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe FoiAttachment, " when calculating due date" do + fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments + + before(:each) do + load_raw_emails_data(raw_emails) + end + + it "sets the body" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + end + it "sets the size" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + attachment.update_display_size! + attachment.display_size.should == "0K" + end + it "reparses the body if it disappears" do + mail_body = load_file_fixture('incoming-request-attach-attachments.email') + mail = TMail::Mail.parse(mail_body) + mail.base64_decode + im = incoming_messages(:useless_incoming_message) + im.stub!(:mail).and_return(mail) + #im.extract_attachments! + attachments = im.get_attachments_for_display + FileUtils.rm attachments[0].filepath + lambda { + attachments = im.get_attachments_for_display + body = attachments[0].body + }.should_not raise_error(Errno::ENOENT) + end +end |