summaryrefslogtreecommitdiffstats
path: root/test/unit/attachment_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-29 15:28:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-07-29 15:28:59 +0000
commit6db66f71836862931d46f0f04e7aa4955b383e6e (patch)
treeca3500cb08ba55f06bb92247d3d7ff8bef4ee33f /test/unit/attachment_test.rb
parentead54750014a260a280208012318e9ae10c55143 (diff)
downloadredmine-6db66f71836862931d46f0f04e7aa4955b383e6e.tar.gz
redmine-6db66f71836862931d46f0f04e7aa4955b383e6e.zip
Fixed: file uploads broken by r6312 (#8912).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6320 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r--test/unit/attachment_test.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 4a57669c1..d433ae757 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -36,6 +36,7 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 0, a.downloads
assert_equal '1478adae0d4eb06d35897518540e25d6', a.digest
assert File.exist?(a.diskfile)
+ assert_equal 59, File.size(a.diskfile)
end
def test_create_should_auto_assign_content_type
@@ -64,7 +65,27 @@ class AttachmentTest < ActiveSupport::TestCase
assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1]
end
- context "Attachmnet#attach_files" do
+ context "Attachmnet.attach_files" do
+ should "attach the file" do
+ issue = Issue.first
+ assert_difference 'Attachment.count' do
+ Attachment.attach_files(issue,
+ '1' => {
+ 'file' => uploaded_test_file('testfile.txt', 'text/plain'),
+ 'description' => 'test'
+ })
+ end
+
+ attachment = Attachment.first(:order => 'id DESC')
+ assert_equal issue, attachment.container
+ assert_equal 'testfile.txt', attachment.filename
+ assert_equal 59, attachment.filesize
+ assert_equal 'test', attachment.description
+ assert_equal 'text/plain', attachment.content_type
+ assert File.exists?(attachment.diskfile)
+ assert_equal 59, File.size(attachment.diskfile)
+ end
+
should "add unsaved files to the object as unsaved attachments" do
# Max size of 0 to force Attachment creation failures
with_settings(:attachment_max_size => 0) do