[Git][noosfero/noosfero][master] 2 commits: Handle privacity in WorkAssignment submissions properly

Daniela Feitosa gitlab at gitlab.com
Fri Oct 2 16:39:45 BRT 2015


Daniela Feitosa pushed to branch master at Noosfero / noosfero


Commits:
bb9580ee by Arthur Del Esposte at 2015-10-02T17:54:57Z
Handle privacity in WorkAssignment submissions properly

- - - - -
c9e5b2d8 by Daniela Feitosa at 2015-10-02T19:39:25Z
Merge branch 'work_assignment_fixies' into 'master'

Handle privacity in WorkAssignment submissions properly

WorkAssingment submissions weren't considering the show_to_follows attribute. As result, the submissions' download privacity did not work properly.

See merge request !690
- - - - -


2 changed files:

- plugins/work_assignment/lib/ext/article.rb
- plugins/work_assignment/test/functional/cms_controller_test.rb


Changes:

=====================================
plugins/work_assignment/lib/ext/article.rb
=====================================
--- a/plugins/work_assignment/lib/ext/article.rb
+++ b/plugins/work_assignment/lib/ext/article.rb
@@ -13,7 +13,13 @@ class Article
   end
 
   def work_assignment_change_visibility
-    if self.parent && self.parent.parent && self.parent.parent.kind_of?(WorkAssignmentPlugin::WorkAssignment)
+    if WorkAssignmentPlugin.is_submission?(self)
+      related_work_assignment = self.parent.parent
+
+      if(!related_work_assignment.publish_submissions)
+        self.show_to_followers = false
+      end
+
       self.published = self.parent.published
     end
   end


=====================================
plugins/work_assignment/test/functional/cms_controller_test.rb
=====================================
--- a/plugins/work_assignment/test/functional/cms_controller_test.rb
+++ b/plugins/work_assignment/test/functional/cms_controller_test.rb
@@ -71,6 +71,31 @@ class CmsControllerTest < ActionController::TestCase
     assert_equal other_work_assignment.publish_submissions, submission.parent.published
   end
 
+  should 'submission inherit Work Assignment "published" attribute and not be set as show_to_followers when it is not public' do
+    @organization.add_member(@person)
+    work_assignment = create_work_assignment('Work Assignment', @organization, false, nil)
+
+    assert !work_assignment.publish_submissions
+
+    post :upload_files, :profile => @organization.identifier, :parent_id => work_assignment.id, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')]
+    submission = UploadedFile.last
+
+    assert !submission.show_to_followers?
+    assert_equal work_assignment.publish_submissions, submission.published
+    assert_equal work_assignment.publish_submissions, submission.parent.published
+
+    other_work_assignment = create_work_assignment('Other Work Assigment', @organization, true, nil)
+
+    assert_equal true, other_work_assignment.publish_submissions
+
+    post :upload_files, :profile => @organization.identifier, :parent_id => other_work_assignment.id, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')]
+    submission = UploadedFile.last
+
+    assert submission.show_to_followers?
+    assert_equal other_work_assignment.publish_submissions, submission.published
+    assert_equal other_work_assignment.publish_submissions, submission.parent.published
+  end
+
   private
     def create_work_assignment(name = nil, profile = nil, publish_submissions = nil, allow_visibility_edition = nil)
       @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => name, :profile => profile, :publish_submissions => publish_submissions, :allow_visibility_edition => allow_visibility_edition)



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/02f4590433758a24fe61463d86eef7539789cdb7...c9e5b2d821c95d3ecb41752f97092d2230991c99
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151002/18cc932b/attachment.html>


More information about the Noosfero-dev mailing list