Mercurial > hg > soundsoftware-site
diff test/unit/attachment_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children | fb9a13467253 |
line wrap: on
line diff
--- a/test/unit/attachment_test.rb Tue Sep 09 09:28:31 2014 +0100 +++ b/test/unit/attachment_test.rb Tue Sep 09 09:29:00 2014 +0100 @@ -22,10 +22,10 @@ class AttachmentTest < ActiveSupport::TestCase fixtures :users, :projects, :roles, :members, :member_roles, :enabled_modules, :issues, :trackers, :attachments - + class MockFile attr_reader :original_filename, :content_type, :content, :size - + def initialize(attributes) @original_filename = attributes[:original_filename] @content_type = attributes[:content_type] @@ -153,12 +153,12 @@ :author => User.find(1)) assert a1.disk_filename != a2.disk_filename end - + def test_filename_should_be_basenamed a = Attachment.new(:file => MockFile.new(:original_filename => "path/to/the/file")) assert_equal 'file', a.filename end - + def test_filename_should_be_sanitized a = Attachment.new(:file => MockFile.new(:original_filename => "valid:[] invalid:?%*|\"'<>chars")) assert_equal 'valid_[] invalid_chars', a.filename @@ -214,8 +214,7 @@ 'description' => 'test' }) end - - attachment = Attachment.first(:order => 'id DESC') + attachment = Attachment.order('id DESC').first assert_equal issue, attachment.container assert_equal 'testfile.txt', attachment.filename assert_equal 59, attachment.filesize @@ -242,6 +241,15 @@ end end + test "Attachment.attach_files should preserve the content_type of attachments added by token" do + @project = Project.find(1) + attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", ""), :author_id => 1, :created_on => 2.days.ago) + assert_equal 'text/plain', attachment.content_type + Attachment.attach_files(@project, { '1' => {'token' => attachment.token } }) + attachment.reload + assert_equal 'text/plain', attachment.content_type + end + def test_latest_attach set_fixtures_attachments_directory a1 = Attachment.find(16)