@@ -4358,6 +4358,45 @@ def test_update_share_called(self, app, collection_with_zero_collection_submissi
43584358 assert res .status_code == 201
43594359 _shmock .assert_called ()
43604360
4361+ def test_private_project_made_public_on_non_moderated_submit (self , app , collection_with_zero_collection_submission , user_one , project_four , url , payload ):
4362+ # Projects are private by default; non-moderated submit should make referent public
4363+ assert not project_four .is_public
4364+
4365+ collection_with_zero_collection_submission .is_public = True
4366+ collection_with_zero_collection_submission .save ()
4367+
4368+ with mock_update_share ():
4369+ res = app .post_json_api (
4370+ url .format (collection_with_zero_collection_submission ._id ),
4371+ payload (guid = project_four ._id ),
4372+ auth = user_one .auth )
4373+ assert res .status_code == 201
4374+
4375+ project_four .refresh_from_db ()
4376+ assert project_four .is_public
4377+
4378+ def test_on_collection_updated_notifies_share_when_collection_goes_public (self , user_one , project_one , project_two ):
4379+ from website .collections .tasks import on_collection_updated
4380+
4381+ collection = CollectionFactory (creator = user_one )
4382+ with mock_update_share ():
4383+ collection .collect_object (project_one , user_one )
4384+ collection .collect_object (project_two , user_one )
4385+
4386+ with mock_update_share () as _shmock :
4387+ on_collection_updated (collection ._id )
4388+
4389+ # on_collection_updated should not call update_share when collection is private
4390+ _shmock .assert_not_called ()
4391+
4392+ with mock_update_share () as _shmock :
4393+ collection .is_public = True
4394+ collection .save ()
4395+ on_collection_updated (collection ._id )
4396+
4397+ # Both accepted submissions should trigger a SHARE update
4398+ assert _shmock .call_count == 2
4399+
43614400 def test_filters (self , app , collection_with_one_collection_submission , collection_with_three_collection_submission , project_two , project_four , user_one , subject_one , url , payload ):
43624401 res = app .get (f'{ url .format (collection_with_three_collection_submission ._id )} ?filter[id]={ project_two ._id } ' , auth = user_one .auth )
43634402 assert res .status_code == 200
0 commit comments