Commit bb9580ee00c20caa533a40d40eae57bd35e9332d
1 parent
9ac9e0ab
Exists in
master
and in
21 other branches
Handle privacity in WorkAssignment submissions properly
Showing
2 changed files
with
32 additions
and
1 deletions
Show diff stats
plugins/work_assignment/lib/ext/article.rb
| ... | ... | @@ -13,7 +13,13 @@ class Article |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | def work_assignment_change_visibility |
| 16 | - if self.parent && self.parent.parent && self.parent.parent.kind_of?(WorkAssignmentPlugin::WorkAssignment) | |
| 16 | + if WorkAssignmentPlugin.is_submission?(self) | |
| 17 | + related_work_assignment = self.parent.parent | |
| 18 | + | |
| 19 | + if(!related_work_assignment.publish_submissions) | |
| 20 | + self.show_to_followers = false | |
| 21 | + end | |
| 22 | + | |
| 17 | 23 | self.published = self.parent.published |
| 18 | 24 | end |
| 19 | 25 | end | ... | ... |
plugins/work_assignment/test/functional/cms_controller_test.rb
| ... | ... | @@ -71,6 +71,31 @@ class CmsControllerTest < ActionController::TestCase |
| 71 | 71 | assert_equal other_work_assignment.publish_submissions, submission.parent.published |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | + should 'submission inherit Work Assignment "published" attribute and not be set as show_to_followers when it is not public' do | |
| 75 | + @organization.add_member(@person) | |
| 76 | + work_assignment = create_work_assignment('Work Assignment', @organization, false, nil) | |
| 77 | + | |
| 78 | + assert !work_assignment.publish_submissions | |
| 79 | + | |
| 80 | + post :upload_files, :profile => @organization.identifier, :parent_id => work_assignment.id, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')] | |
| 81 | + submission = UploadedFile.last | |
| 82 | + | |
| 83 | + assert !submission.show_to_followers? | |
| 84 | + assert_equal work_assignment.publish_submissions, submission.published | |
| 85 | + assert_equal work_assignment.publish_submissions, submission.parent.published | |
| 86 | + | |
| 87 | + other_work_assignment = create_work_assignment('Other Work Assigment', @organization, true, nil) | |
| 88 | + | |
| 89 | + assert_equal true, other_work_assignment.publish_submissions | |
| 90 | + | |
| 91 | + post :upload_files, :profile => @organization.identifier, :parent_id => other_work_assignment.id, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain')] | |
| 92 | + submission = UploadedFile.last | |
| 93 | + | |
| 94 | + assert submission.show_to_followers? | |
| 95 | + assert_equal other_work_assignment.publish_submissions, submission.published | |
| 96 | + assert_equal other_work_assignment.publish_submissions, submission.parent.published | |
| 97 | + end | |
| 98 | + | |
| 74 | 99 | private |
| 75 | 100 | def create_work_assignment(name = nil, profile = nil, publish_submissions = nil, allow_visibility_edition = nil) |
| 76 | 101 | @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => name, :profile => profile, :publish_submissions => publish_submissions, :allow_visibility_edition => allow_visibility_edition) | ... | ... |