@@ -22,10 +22,10 require File.expand_path('../../test_helper', __FILE__) | |||
|
22 | 22 | class AttachmentTest < ActiveSupport::TestCase |
|
23 | 23 | fixtures :users, :projects, :roles, :members, :member_roles, |
|
24 | 24 | :enabled_modules, :issues, :trackers, :attachments |
|
25 | ||
|
25 | ||
|
26 | 26 | class MockFile |
|
27 | 27 | attr_reader :original_filename, :content_type, :content, :size |
|
28 | ||
|
28 | ||
|
29 | 29 | def initialize(attributes) |
|
30 | 30 | @original_filename = attributes[:original_filename] |
|
31 | 31 | @content_type = attributes[:content_type] |
@@ -153,12 +153,12 class AttachmentTest < ActiveSupport::TestCase | |||
|
153 | 153 | :author => User.find(1)) |
|
154 | 154 | assert a1.disk_filename != a2.disk_filename |
|
155 | 155 | end |
|
156 | ||
|
156 | ||
|
157 | 157 | def test_filename_should_be_basenamed |
|
158 | 158 | a = Attachment.new(:file => MockFile.new(:original_filename => "path/to/the/file")) |
|
159 | 159 | assert_equal 'file', a.filename |
|
160 | 160 | end |
|
161 | ||
|
161 | ||
|
162 | 162 | def test_filename_should_be_sanitized |
|
163 | 163 | a = Attachment.new(:file => MockFile.new(:original_filename => "valid:[] invalid:?%*|\"'<>chars")) |
|
164 | 164 | assert_equal 'valid_[] invalid_chars', a.filename |
General Comments 0
You need to be logged in to leave comments.
Login now