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

Proposed by Colin Watson
Status: Merged
Merged at revision: 17699
Proposed branch: lp:~cjwatson/launchpad/answers-mail-permissions
Merge into: lp:launchpad
Diff against target: 67 lines (+9/-4)
2 files modified
database/schema/security.cfg (+1/-0)
lib/lp/answers/tests/test_questionjob.py (+8/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/answers-mail-permissions
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+269241@code.launchpad.net

Commit message

Fix QuestionEmailJob OOPS when sending notifications to team members.

Description of the change

Fix QuestionEmailJob OOPS when sending notifications to team members.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
1291public.questionsubscription = SELECT1291public.questionsubscription = SELECT
1292public.sourcepackagename = SELECT1292public.sourcepackagename = SELECT
1293public.teammembership = SELECT1293public.teammembership = SELECT
1294public.teamparticipation = SELECT
1294public.validpersoncache = SELECT1295public.validpersoncache = SELECT
1295public.validpersonorteamcache = SELECT1296public.validpersonorteamcache = SELECT
1296type=user1297type=user
12971298
=== 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 @@
1# Copyright 2011 Canonical Ltd. This software is licensed under the1# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for QuestionJobs classes."""4"""Tests for QuestionJobs classes."""
@@ -25,6 +25,7 @@
25 QuestionEmailJob,25 QuestionEmailJob,
26 QuestionJob,26 QuestionJob,
27 )27 )
28from lp.services.config import config
28from lp.services.database.interfaces import IStore29from lp.services.database.interfaces import IStore
29from lp.services.features.testing import FeatureFixture30from lp.services.features.testing import FeatureFixture
30from lp.services.job.interfaces.job import JobStatus31from lp.services.job.interfaces.job import JobStatus
@@ -45,6 +46,7 @@
45 run_script,46 run_script,
46 TestCaseWithFactory,47 TestCaseWithFactory,
47 )48 )
49from lp.testing.dbuser import dbuser
48from lp.testing.layers import (50from lp.testing.layers import (
49 CeleryJobLayer,51 CeleryJobLayer,
50 DatabaseFunctionalLayer,52 DatabaseFunctionalLayer,
@@ -291,8 +293,10 @@
291 # The email is sent to all the recipients.293 # The email is sent to all the recipients.
292 job = make_question_job(294 job = make_question_job(
293 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER)295 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER)
296 team_subscriber = self.factory.makeTeam()
297 job.question.subscribe(team_subscriber)
294 logger = BufferLogger()298 logger = BufferLogger()
295 with log.use(logger):299 with dbuser(config.answertracker.dbuser), log.use(logger):
296 job.run()300 job.run()
297 self.assertEqual(301 self.assertEqual(
298 ["DEBUG QuestionEmailJob will send email for question %s." %302 ["DEBUG QuestionEmailJob will send email for question %s." %
@@ -301,7 +305,7 @@
301 job.question.id],305 job.question.id],
302 logger.getLogBuffer().splitlines())306 logger.getLogBuffer().splitlines())
303 transaction.commit()307 transaction.commit()
304 self.assertEqual(2, len(stub.test_emails))308 self.assertEqual(3, len(stub.test_emails))
305309
306 def test_run_cronscript(self):310 def test_run_cronscript(self):
307 # The cronscript is configured: schema-lazr.conf and security.cfg.311 # The cronscript is configured: schema-lazr.conf and security.cfg.
@@ -354,7 +358,7 @@
354 make_question_job(358 make_question_job(
355 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER,359 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER,
356 question=question, body=body)360 question=question, body=body)
357 with block_on_job(self):361 with dbuser(config.answertracker.dbuser), block_on_job(self):
358 transaction.commit()362 transaction.commit()
359 transaction.commit()363 transaction.commit()
360 mail = pop_remote_notifications()364 mail = pop_remote_notifications()