From 19ef92f84585198ee67cdcf9b37973b767409feb Mon Sep 17 00:00:00 2001
From: tom <tom@teamfay.co.uk>
Date: Sat, 12 Dec 2015 11:29:27 +0000
Subject: [PATCH 2/2] Add test to check that an activity is created when a
 collection was chosen.

---
 mediagoblin/tests/test_submission.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py
index eed7afa..0ec49ec 100644
--- a/mediagoblin/tests/test_submission.py
+++ b/mediagoblin/tests/test_submission.py
@@ -36,7 +36,7 @@ Gst.init(None)
 from mediagoblin.tests.tools import fixture_add_user, fixture_add_collection
 from .media_tools import create_av
 from mediagoblin import mg_globals
-from mediagoblin.db.models import MediaEntry, User, LocalUser
+from mediagoblin.db.models import MediaEntry, User, LocalUser, Activity
 from mediagoblin.db.base import Session
 from mediagoblin.tools import template
 from mediagoblin.media_types.image import ImageMediaManager
@@ -426,14 +426,14 @@ class TestSubmission:
     def test_collection_selection(self):
         """Test the ability to choose a collection when submitting media
         """
-        # Collection option shouldn't be present if the user has no collections
+        # Collection option should have been removed if the user has no
+        # collections.
         response = self.test_app.get('/submit/')
         assert 'collection' not in response.form.fields
 
+        # Test upload of an image when a user has no collections.
         upload = webtest.forms.Upload(os.path.join(
             'mediagoblin', 'static', 'images', 'media_thumbs', 'image.png'))
-
-        # Check that upload of an image when a user has no collections
         response.form['file'] = upload
         no_collection_title = 'no collection'
         response.form['title'] = no_collection_title
@@ -466,6 +466,13 @@ class TestSubmission:
         col = self.our_user().collections[0]
         assert col.collection_items[0].get_object().title == title
 
+        # Test that an activity was created when the item was added to the
+        # collection. That should be the last activity.
+        assert Activity.query.order_by(
+            Activity.id.desc()
+        ).first().content == '{0} added new picture to {1}'.format(
+            self.our_user().username, col.title)
+
         # Test upload succeeds if the user has collection and no collection is
         # chosen.
         form['file'] = webtest.forms.Upload(os.path.join(
-- 
2.6.3

