Commit 0d2f2d57738e4c1989ab3c07fda9437edb8a476f
1 parent
46cba55f
Exists in
master
and in
29 other branches
ActionItem24: checkpoint
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1135 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
34 additions
and
4 deletions
Show diff stats
app/helpers/cms_helper.rb
app/models/uploaded_file.rb
... | ... | @@ -4,7 +4,11 @@ class UploadedFile < Article |
4 | 4 | has_attachment :thumbnails => { :icon => [24,24] } |
5 | 5 | |
6 | 6 | def icon_name |
7 | - public_filename(:icon) | |
7 | + self.image? ? public_filename(:icon) : self.content_type.gsub('/', '-') | |
8 | + end | |
9 | + | |
10 | + def mime_type | |
11 | + content_type | |
8 | 12 | end |
9 | 13 | |
10 | 14 | end | ... | ... |
app/views/cms/view.rhtml
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | <ul> |
29 | 29 | <% @subitems.each do |item| %> |
30 | 30 | <li> |
31 | - <%= file_manager_button(item.name, "icons-mime/#{item.icon_name}", :action => 'view', :id => item.id) %> | |
31 | + <%= file_manager_button(item.name, icon_for_article(item), :action => 'view', :id => item.id) %> | |
32 | 32 | </li> |
33 | 33 | <% end %> |
34 | 34 | </ul> | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -162,4 +162,12 @@ class CmsControllerTest < Test::Unit::TestCase |
162 | 162 | assert_equal 'parent_and_children', updated.include |
163 | 163 | end |
164 | 164 | |
165 | + should 'be able to upload a file' do | |
166 | + flunk 'pending' | |
167 | + end | |
168 | + | |
169 | + should 'be able to update an uploaded file' do | |
170 | + flunk 'pending' | |
171 | + end | |
172 | + | |
165 | 173 | end | ... | ... |
test/unit/uploaded_file_test.rb
... | ... | @@ -2,10 +2,23 @@ require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | 3 | class UploadedFileTest < Test::Unit::TestCase |
4 | 4 | |
5 | - should 'return a thumbnail as icon' do | |
5 | + should 'return a thumbnail as icon for images ' do | |
6 | 6 | f = UploadedFile.new |
7 | + f.expects(:image?).returns(true) | |
7 | 8 | f.expects(:public_filename).with(:icon).returns('/path/to/file.xyz') |
8 | 9 | assert_equal '/path/to/file.xyz', f.icon_name |
9 | 10 | end |
10 | - | |
11 | + | |
12 | + should 'return mime-type icon for non-image files' do | |
13 | + f= UploadedFile.new | |
14 | + f.expects(:image?).returns(false) | |
15 | + f.expects(:content_type).returns('application/pdf') | |
16 | + assert_equal 'application-pdf', f.icon_name | |
17 | + end | |
18 | + | |
19 | + should 'use attachment_fu content_type method to return mime_type' do | |
20 | + f = UploadedFile.new | |
21 | + f.expects(:content_type).returns('application/pdf') | |
22 | + assert_equal 'application/pdf', f.mime_type | |
23 | + end | |
11 | 24 | end | ... | ... |