Commit c51c60ec73a1a9f858c8ebb7d2a990e0b07e5a17
1 parent
59897e5e
Exists in
master
and in
29 other branches
upload-file: fix work_assignment plugin for don't remove upload file
AI2770
Showing
3 changed files
with
13 additions
and
2 deletions
Show diff stats
plugins/work_assignment/lib/work_assignment_plugin.rb
@@ -32,7 +32,9 @@ class WorkAssignmentPlugin < Noosfero::Plugin | @@ -32,7 +32,9 @@ class WorkAssignmentPlugin < Noosfero::Plugin | ||
32 | end | 32 | end |
33 | 33 | ||
34 | def content_remove_upload(content) | 34 | def content_remove_upload(content) |
35 | - !content.profile.members.include?(context.send(:user)) | 35 | + if content.kind_of?(WorkAssignmentPlugin::WorkAssignment) |
36 | + !content.profile.members.include?(context.send(:user)) | ||
37 | + end | ||
36 | end | 38 | end |
37 | 39 | ||
38 | def content_viewer_controller_filters | 40 | def content_viewer_controller_filters |
plugins/work_assignment/test/functional/content_viewer_controller_test.rb
@@ -10,6 +10,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -10,6 +10,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
10 | @controller = ContentViewerController.new | 10 | @controller = ContentViewerController.new |
11 | @request = ActionController::TestRequest.new | 11 | @request = ActionController::TestRequest.new |
12 | @response = ActionController::TestResponse.new | 12 | @response = ActionController::TestResponse.new |
13 | + @profile = create_user('testinguser').person | ||
13 | 14 | ||
14 | @organization = fast_create(Organization) | 15 | @organization = fast_create(Organization) |
15 | @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => @organization) | 16 | @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => @organization) |
@@ -19,7 +20,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -19,7 +20,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
19 | @environment.save! | 20 | @environment.save! |
20 | login_as(:test_user) | 21 | login_as(:test_user) |
21 | end | 22 | end |
22 | - attr_reader :organization, :person, :work_assignment | 23 | + attr_reader :organization, :person, :profile, :work_assignment |
23 | 24 | ||
24 | should 'can download work_assignment' do | 25 | should 'can download work_assignment' do |
25 | random_member = fast_create(Person) | 26 | random_member = fast_create(Person) |
@@ -38,4 +39,11 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -38,4 +39,11 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
38 | assert_response :success | 39 | assert_response :success |
39 | end | 40 | end |
40 | 41 | ||
42 | + should "display 'Upload files' when create children of image gallery" do | ||
43 | + login_as(profile.identifier) | ||
44 | + f = Gallery.create!(:name => 'gallery', :profile => profile) | ||
45 | + xhr :get, :view_page, :profile => profile.identifier, :page => f.explode_path, :toolbar => true | ||
46 | + assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{f.id}/} | ||
47 | + end | ||
48 | + | ||
41 | end | 49 | end |
plugins/work_assignment/test/unit/work_assingment_plugin_test.rb
@@ -43,6 +43,7 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase | @@ -43,6 +43,7 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase | ||
43 | assert WorkAssignmentPlugin.can_download_submission?(moderator, submission) | 43 | assert WorkAssignmentPlugin.can_download_submission?(moderator, submission) |
44 | end | 44 | end |
45 | 45 | ||
46 | + | ||
46 | private | 47 | private |
47 | 48 | ||
48 | def create_submission(author=nil) | 49 | def create_submission(author=nil) |