diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-01-14 14:45:41 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-01-14 14:49:43 +0000 |
commit | 07121bf22b0929e03215f02b8740c3979ae6c872 (patch) | |
tree | 4df8810a8120ee6ee1f439443508d8cf18c86171 /spec/models | |
parent | 285c2b7836b49db196a2fde4ba9fbe851c403882 (diff) |
As we're validating filename with validates_presence_of, which doesn't allow blanks, ensure_filename! should populate a default filename on a blank filename, as well as on nil.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/foi_attachment_spec.rb | 13 |
1 files changed, 12 insertions, 1 deletions
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 |