← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/answers-mail-permissions into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/answers-mail-permissions into lp:launchpad.

Commit message:
Fix QuestionEmailJob OOPS when sending notifications to team members.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #968578 in Launchpad itself: "Unable to figure out why I got mail about a question"
  https://bugs.launchpad.net/launchpad/+bug/968578

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/answers-mail-permissions/+merge/269241

Fix QuestionEmailJob OOPS when sending notifications to team members.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/answers-mail-permissions into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2015-08-10 10:58:28 +0000
+++ database/schema/security.cfg	2015-08-26 16:27:30 +0000
@@ -1291,6 +1291,7 @@
 public.questionsubscription             = SELECT
 public.sourcepackagename                = SELECT
 public.teammembership                   = SELECT
+public.teamparticipation                = SELECT
 public.validpersoncache                 = SELECT
 public.validpersonorteamcache           = SELECT
 type=user

=== modified file 'lib/lp/answers/tests/test_questionjob.py'
--- lib/lp/answers/tests/test_questionjob.py	2013-06-20 05:50:00 +0000
+++ lib/lp/answers/tests/test_questionjob.py	2015-08-26 16:27:30 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for QuestionJobs classes."""
@@ -25,6 +25,7 @@
     QuestionEmailJob,
     QuestionJob,
     )
+from lp.services.config import config
 from lp.services.database.interfaces import IStore
 from lp.services.features.testing import FeatureFixture
 from lp.services.job.interfaces.job import JobStatus
@@ -45,6 +46,7 @@
     run_script,
     TestCaseWithFactory,
     )
+from lp.testing.dbuser import dbuser
 from lp.testing.layers import (
     CeleryJobLayer,
     DatabaseFunctionalLayer,
@@ -291,8 +293,10 @@
         # The email is sent to all the recipients.
         job = make_question_job(
             self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER)
+        team_subscriber = self.factory.makeTeam()
+        job.question.subscribe(team_subscriber)
         logger = BufferLogger()
-        with log.use(logger):
+        with dbuser(config.answertracker.dbuser), log.use(logger):
             job.run()
         self.assertEqual(
             ["DEBUG QuestionEmailJob will send email for question %s." %
@@ -301,7 +305,7 @@
              job.question.id],
             logger.getLogBuffer().splitlines())
         transaction.commit()
-        self.assertEqual(2, len(stub.test_emails))
+        self.assertEqual(3, len(stub.test_emails))
 
     def test_run_cronscript(self):
         # The cronscript is configured: schema-lazr.conf and security.cfg.
@@ -354,7 +358,7 @@
         make_question_job(
             self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER,
             question=question, body=body)
-        with block_on_job(self):
+        with dbuser(config.answertracker.dbuser), block_on_job(self):
             transaction.commit()
         transaction.commit()
         mail = pop_remote_notifications()


Follow ups