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
1=== modified file 'database/schema/security.cfg'
2--- database/schema/security.cfg 2015-08-10 10:58:28 +0000
3+++ database/schema/security.cfg 2015-08-26 16:27:30 +0000
4@@ -1291,6 +1291,7 @@
5 public.questionsubscription = SELECT
6 public.sourcepackagename = SELECT
7 public.teammembership = SELECT
8+public.teamparticipation = SELECT
9 public.validpersoncache = SELECT
10 public.validpersonorteamcache = SELECT
11 type=user
12
13=== modified file 'lib/lp/answers/tests/test_questionjob.py'
14--- lib/lp/answers/tests/test_questionjob.py 2013-06-20 05:50:00 +0000
15+++ lib/lp/answers/tests/test_questionjob.py 2015-08-26 16:27:30 +0000
16@@ -1,4 +1,4 @@
17-# Copyright 2011 Canonical Ltd. This software is licensed under the
18+# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
19 # GNU Affero General Public License version 3 (see the file LICENSE).
20
21 """Tests for QuestionJobs classes."""
22@@ -25,6 +25,7 @@
23 QuestionEmailJob,
24 QuestionJob,
25 )
26+from lp.services.config import config
27 from lp.services.database.interfaces import IStore
28 from lp.services.features.testing import FeatureFixture
29 from lp.services.job.interfaces.job import JobStatus
30@@ -45,6 +46,7 @@
31 run_script,
32 TestCaseWithFactory,
33 )
34+from lp.testing.dbuser import dbuser
35 from lp.testing.layers import (
36 CeleryJobLayer,
37 DatabaseFunctionalLayer,
38@@ -291,8 +293,10 @@
39 # The email is sent to all the recipients.
40 job = make_question_job(
41 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER)
42+ team_subscriber = self.factory.makeTeam()
43+ job.question.subscribe(team_subscriber)
44 logger = BufferLogger()
45- with log.use(logger):
46+ with dbuser(config.answertracker.dbuser), log.use(logger):
47 job.run()
48 self.assertEqual(
49 ["DEBUG QuestionEmailJob will send email for question %s." %
50@@ -301,7 +305,7 @@
51 job.question.id],
52 logger.getLogBuffer().splitlines())
53 transaction.commit()
54- self.assertEqual(2, len(stub.test_emails))
55+ self.assertEqual(3, len(stub.test_emails))
56
57 def test_run_cronscript(self):
58 # The cronscript is configured: schema-lazr.conf and security.cfg.
59@@ -354,7 +358,7 @@
60 make_question_job(
61 self.factory, QuestionRecipientSet.ASKER_SUBSCRIBER,
62 question=question, body=body)
63- with block_on_job(self):
64+ with dbuser(config.answertracker.dbuser), block_on_job(self):
65 transaction.commit()
66 transaction.commit()
67 mail = pop_remote_notifications()