Feature #22482 » 0003-Show-attachment-view-even-is-no-preview-is-available.patch
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 43 | 43 |
elsif @attachment.is_image? |
| 44 | 44 |
render :action => 'image' |
| 45 | 45 |
else |
| 46 |
download
|
|
| 46 |
render :action => 'other'
|
|
| 47 | 47 |
end |
| 48 | 48 |
} |
| 49 | 49 |
format.api |
| app/views/attachments/other.html.erb | ||
|---|---|---|
| 1 |
<%= render :layout => 'layouts/file' do %> |
|
| 2 |
<%= render :partial => 'common/other' %> |
|
| 3 |
<% end %> |
|
| test/functional/attachments_controller_test.rb | ||
|---|---|---|
| 179 | 179 |
end |
| 180 | 180 |
end |
| 181 | 181 | |
| 182 |
def test_show_text_file_should_send_if_too_big
|
|
| 182 |
def test_show_text_file_should_show_other_if_too_big
|
|
| 183 | 183 |
with_settings :file_max_size_displayed => 512 do |
| 184 | 184 |
Attachment.find(4).update_attribute :filesize, 754.kilobyte |
| 185 | 185 |
get :show, :id => 4 |
| 186 | 186 |
assert_response :success |
| 187 |
assert_equal 'application/x-ruby', @response.content_type |
|
| 187 |
assert_template 'other' |
|
| 188 |
assert_equal 'text/html', @response.content_type |
|
| 188 | 189 |
end |
| 189 | 190 |
set_tmp_attachments_directory |
| 190 | 191 |
end |
| ... | ... | |
| 199 | 200 |
end |
| 200 | 201 |
def test_show_other |
| 201 | 202 |
get :show, :id => 6 |
| 202 |
assert_response :success |
|
| 203 |
assert_equal 'application/zip', @response.content_type |
|
| 203 |
assert_template 'other' |
|
| 204 |
assert_equal 'text/html', @response.content_type |
|
| 205 |
assert_select '.nodata', :text => 'No preview available' |
|
| 204 | 206 |
set_tmp_attachments_directory |
| 205 | 207 |
end |
| 206 | 208 | |