Commit c51c60ec73a1a9f858c8ebb7d2a990e0b07e5a17

Authored by Junior Silva
1 parent 59897e5e

upload-file: fix work_assignment plugin for don't remove upload file

AI2770
plugins/work_assignment/lib/work_assignment_plugin.rb
... ... @@ -32,7 +32,9 @@ class WorkAssignmentPlugin < Noosfero::Plugin
32 32 end
33 33  
34 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 38 end
37 39  
38 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 10 @controller = ContentViewerController.new
11 11 @request = ActionController::TestRequest.new
12 12 @response = ActionController::TestResponse.new
  13 + @profile = create_user('testinguser').person
13 14  
14 15 @organization = fast_create(Organization)
15 16 @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => @organization)
... ... @@ -19,7 +20,7 @@ class ContentViewerControllerTest < ActionController::TestCase
19 20 @environment.save!
20 21 login_as(:test_user)
21 22 end
22   - attr_reader :organization, :person, :work_assignment
  23 + attr_reader :organization, :person, :profile, :work_assignment
23 24  
24 25 should 'can download work_assignment' do
25 26 random_member = fast_create(Person)
... ... @@ -38,4 +39,11 @@ class ContentViewerControllerTest < ActionController::TestCase
38 39 assert_response :success
39 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 49 end
... ...
plugins/work_assignment/test/unit/work_assingment_plugin_test.rb
... ... @@ -43,6 +43,7 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase
43 43 assert WorkAssignmentPlugin.can_download_submission?(moderator, submission)
44 44 end
45 45  
  46 +
46 47 private
47 48  
48 49 def create_submission(author=nil)
... ...