From c51c60ec73a1a9f858c8ebb7d2a990e0b07e5a17 Mon Sep 17 00:00:00 2001 From: Junior Silva Date: Mon, 26 Aug 2013 18:20:05 +0000 Subject: [PATCH] upload-file: fix work_assignment plugin for don't remove upload file --- plugins/work_assignment/lib/work_assignment_plugin.rb | 4 +++- plugins/work_assignment/test/functional/content_viewer_controller_test.rb | 10 +++++++++- plugins/work_assignment/test/unit/work_assingment_plugin_test.rb | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/work_assignment/lib/work_assignment_plugin.rb b/plugins/work_assignment/lib/work_assignment_plugin.rb index 70527cf..46bde51 100644 --- a/plugins/work_assignment/lib/work_assignment_plugin.rb +++ b/plugins/work_assignment/lib/work_assignment_plugin.rb @@ -32,7 +32,9 @@ class WorkAssignmentPlugin < Noosfero::Plugin end def content_remove_upload(content) - !content.profile.members.include?(context.send(:user)) + if content.kind_of?(WorkAssignmentPlugin::WorkAssignment) + !content.profile.members.include?(context.send(:user)) + end end def content_viewer_controller_filters diff --git a/plugins/work_assignment/test/functional/content_viewer_controller_test.rb b/plugins/work_assignment/test/functional/content_viewer_controller_test.rb index b3c4ece..dc6b28f 100644 --- a/plugins/work_assignment/test/functional/content_viewer_controller_test.rb +++ b/plugins/work_assignment/test/functional/content_viewer_controller_test.rb @@ -10,6 +10,7 @@ class ContentViewerControllerTest < ActionController::TestCase @controller = ContentViewerController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + @profile = create_user('testinguser').person @organization = fast_create(Organization) @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => @organization) @@ -19,7 +20,7 @@ class ContentViewerControllerTest < ActionController::TestCase @environment.save! login_as(:test_user) end - attr_reader :organization, :person, :work_assignment + attr_reader :organization, :person, :profile, :work_assignment should 'can download work_assignment' do random_member = fast_create(Person) @@ -38,4 +39,11 @@ class ContentViewerControllerTest < ActionController::TestCase assert_response :success end + should "display 'Upload files' when create children of image gallery" do + login_as(profile.identifier) + f = Gallery.create!(:name => 'gallery', :profile => profile) + xhr :get, :view_page, :profile => profile.identifier, :page => f.explode_path, :toolbar => true + assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{f.id}/} + end + end diff --git a/plugins/work_assignment/test/unit/work_assingment_plugin_test.rb b/plugins/work_assignment/test/unit/work_assingment_plugin_test.rb index fd15061..17a39b7 100644 --- a/plugins/work_assignment/test/unit/work_assingment_plugin_test.rb +++ b/plugins/work_assignment/test/unit/work_assingment_plugin_test.rb @@ -43,6 +43,7 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase assert WorkAssignmentPlugin.can_download_submission?(moderator, submission) end + private def create_submission(author=nil) -- libgit2 0.21.2