Defect #44126 » svg-preview-fix.patch
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 56 | 56 |
User.current.preference.save |
| 57 | 57 |
end |
| 58 | 58 |
render :action => 'diff' |
| 59 |
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte |
|
| 60 |
@content = File.read(@attachment.diskfile, :mode => "rb") |
|
| 61 |
render :action => 'file' |
|
| 62 | 59 |
elsif @attachment.is_image? |
| 63 | 60 |
render :action => 'image' |
| 64 | 61 |
elsif @attachment.is_pdf? |
| 65 | 62 |
render :action => 'pdf' |
| 63 |
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte |
|
| 64 |
@content = File.read(@attachment.diskfile, :mode => "rb") |
|
| 65 |
render :action => 'file' |
|
| 66 | 66 |
elsif @content = @attachment.markdownized_preview_content |
| 67 | 67 |
render :action => 'markdownized' |
| 68 | 68 |
else |
| test/functional/attachments_controller_test.rb | ||
|---|---|---|
| 241 | 241 |
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename |
| 242 | 242 |
end |
| 243 | 243 | |
| 244 |
def test_show_svg_file_as_image |
|
| 245 |
set_tmp_attachments_directory |
|
| 246 |
attachment = Attachment.create!( |
|
| 247 |
:container => Issue.find(1), |
|
| 248 |
:file => uploaded_test_file('testfile.svg', 'image/svg+xml'),
|
|
| 249 |
:author => User.find(1) |
|
| 250 |
) |
|
| 251 | ||
| 252 |
get(:show, :params => {:id => attachment.id})
|
|
| 253 | ||
| 254 |
assert_response :success |
|
| 255 |
assert_equal 'text/html', @response.media_type |
|
| 256 |
assert_select 'img.filecontent', :src => attachment.filename |
|
| 257 |
end |
|
| 258 | ||
| 244 | 259 |
def test_show_pdf |
| 245 | 260 |
@request.session[:user_id] = 2 |
| 246 | 261 |
get(:show, :params => {:id => 23})
|
- « Previous
- 1
- 2
- 3
- Next »