Commit 86e5a2dbf50446ecc306096f195edb34fc13c63e
Committed by
Daniela Feitosa
1 parent
236951da
Exists in
master
and in
29 other branches
Do not duplicate link "Upload files" on Enterprise's gallery
(ActionItem1932)
Showing
9 changed files
with
97 additions
and
5 deletions
Show diff stats
app/models/article.rb
app/models/folder.rb
... | ... | @@ -53,4 +53,9 @@ class Folder < Article |
53 | 53 | :foreign_key => 'parent_id', |
54 | 54 | :order => 'articles.type, articles.name', |
55 | 55 | :conditions => ["articles.type = 'UploadedFile' and articles.content_type in (?) or articles.type in ('Folder','Gallery')", UploadedFile.content_types] |
56 | + | |
57 | + def accept_uploads? | |
58 | + !self.has_posts? || self.gallery? | |
59 | + end | |
60 | + | |
56 | 61 | end | ... | ... |
app/views/content_viewer/view_page.rhtml
... | ... | @@ -42,12 +42,9 @@ |
42 | 42 | :class => 'button with-text icon-locale' if @page.translatable? && !@page.native_translation.language.blank? %> |
43 | 43 | <%= lightbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) %> |
44 | 44 | <% end %> |
45 | - <% if (@page.folder? && !@page.has_posts?) || (@page.parent && @page.parent.folder? && !@page.parent.has_posts?) %> | |
46 | - <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) %> | |
47 | - <% end %> | |
48 | 45 | <% end %> |
49 | - <% if profile.kind_of?(Enterprise) && @page.gallery? %> | |
50 | - <%= button('upload-file', _('Upload files'), :controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent)) %> | |
46 | + <% if @page.accept_uploads? %> | |
47 | + <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) %> | |
51 | 48 | <% end %> |
52 | 49 | </div> |
53 | 50 | <% elsif profile.community? && (@page.blog? || @page.parent && @page.parent.blog?) %> | ... | ... |
... | ... | @@ -0,0 +1,42 @@ |
1 | +Feature: upload files | |
2 | + As a logged user | |
3 | + I want to upload files | |
4 | + | |
5 | + Background: | |
6 | + Given the following users | |
7 | + | login | name | | |
8 | + | joaosilva | Joao Silva | | |
9 | + And I am logged in as "joaosilva" | |
10 | + | |
11 | + | |
12 | + Scenario: provile links to upload files to community's gallery | |
13 | + Given the following communities | |
14 | + | identifier | name | owner | | |
15 | + | sample-community | Sample Community | joaosilva | | |
16 | + And the following galleries | |
17 | + | owner | name | | |
18 | + | sample-community | Gallery test | | |
19 | + And I go to Sample Community's profile | |
20 | + And I follow "0 pictures" | |
21 | + And I should see "Upload files" | |
22 | + | |
23 | + Scenario: provile links to upload files to enterprise's gallery | |
24 | + Given the following enterprises | |
25 | + | identifier | name | owner | | |
26 | + | sample-enterprise | Sample Enterprise | joaosilva | | |
27 | + And the following galleries | |
28 | + | owner | name | | |
29 | + | sample-enterprise | Gallery test | | |
30 | + And I go to Sample Enterprise's profile | |
31 | + And I follow "0 pictures" | |
32 | + And I should see "Upload files" | |
33 | + | |
34 | + Scenario: not provile links to upload files on blogs | |
35 | + Given the following communities | |
36 | + | identifier | name | owner | | |
37 | + | sample-community | Sample Community | joaosilva | | |
38 | + And the following blogs | |
39 | + | owner | name | | |
40 | + | sample-community | Blog test | | |
41 | + And I go to Sample Community's blog | |
42 | + And I should not see "Upload files" | ... | ... |
test/unit/article_test.rb
... | ... | @@ -1474,4 +1474,28 @@ class ArticleTest < Test::Unit::TestCase |
1474 | 1474 | end |
1475 | 1475 | end |
1476 | 1476 | |
1477 | + should 'accept uploads if parent accept uploads' do | |
1478 | + folder = fast_create(Folder) | |
1479 | + child = fast_create(UploadedFile, :parent_id => folder.id) | |
1480 | + assert folder.accept_uploads? | |
1481 | + assert child.accept_uploads? | |
1482 | + end | |
1483 | + | |
1484 | + should 'not accept uploads if has no parent' do | |
1485 | + child = fast_create(UploadedFile) | |
1486 | + assert !child.accept_uploads? | |
1487 | + end | |
1488 | + | |
1489 | + should 'not accept uploads if parent is a blog' do | |
1490 | + folder = fast_create(Blog) | |
1491 | + child = fast_create(UploadedFile, :parent_id => folder.id) | |
1492 | + assert !child.accept_uploads? | |
1493 | + end | |
1494 | + | |
1495 | + should 'not accept uploads if parent is a forum' do | |
1496 | + folder = fast_create(Forum) | |
1497 | + child = fast_create(UploadedFile, :parent_id => folder.id) | |
1498 | + assert !child.accept_uploads? | |
1499 | + end | |
1500 | + | |
1477 | 1501 | end | ... | ... |
test/unit/blog_test.rb
test/unit/folder_test.rb
test/unit/forum_test.rb
test/unit/gallery_test.rb