allura
Revision | 9e5ba02e8aafb862fb68ce13ce0512cd5999948a (tree) |
---|---|
Zeit | 2012-04-19 06:44:28 |
Autor | Tim Van Steenburgh <tvansteenburgh@geek...> |
Commiter | Jenny Steele |
[#4014] Tracker not sending notification mail.
1. Fixes a 500 in tracker notifications if project-level
2. To accomodate migrated projects that may not have the default
Signed-off-by: Tim Van Steenburgh <tvansteenburgh@geek.net>
@@ -407,7 +407,7 @@ class Ticket(VersionedArtifact): | ||
407 | 407 | Thread(discussion_id=self.app_config.discussion_id, |
408 | 408 | ref_id=self.index_id()) |
409 | 409 | n = Notification.post(artifact=self, topic='metadata', text=description, subject=subject) |
410 | - if monitoring_email: | |
410 | + if monitoring_email and n: | |
411 | 411 | n.send_simple(monitoring_email) |
412 | 412 | Feed.post(self, description) |
413 | 413 |
@@ -45,6 +45,22 @@ class TestMilestones(TrackerTestController): | ||
45 | 45 | r = self.app.get('/bugs/milestones') |
46 | 46 | assert '1 / 2' in r, r.showbrowser() |
47 | 47 | |
48 | + def test_default_milestone_created_if_missing(self): | |
49 | + p = M.Project.query.get(shortname='test') | |
50 | + app = p.app_instance('bugs') | |
51 | + app.globals.custom_fields = [] | |
52 | + ThreadLocalORMSession.flush_all() | |
53 | + r = self.app.post('/bugs/update_milestones',{ | |
54 | + 'field_name':'_milestone', | |
55 | + 'milestones-0.old_name':'', | |
56 | + 'milestones-0.new_name':'1.0', | |
57 | + 'milestones-0.description':'Version 1', | |
58 | + 'milestones-0.complete':'Open', | |
59 | + 'milestones-0.due_date':'' | |
60 | + }) | |
61 | + r = self.app.get('/bugs/milestones') | |
62 | + assert 'Version 1' in r | |
63 | + | |
48 | 64 | class TestFunctionalController(TrackerTestController): |
49 | 65 | def test_bad_ticket_number(self): |
50 | 66 | self.app.get('/bugs/input.project_user_select', status=404) |
@@ -912,6 +928,18 @@ class TestEmailMonitoring(TrackerTestController): | ||
912 | 928 | assert send_simple.call_count == 1, send_simple.call_count |
913 | 929 | send_simple.assert_called_with(self.test_email) |
914 | 930 | |
931 | + @patch('forgetracker.tracker_main.M.Notification.send_simple') | |
932 | + def test_notifications_off(self, send_simple): | |
933 | + """Test that tracker notification email is not sent if notifications | |
934 | + are disabled at the project level. | |
935 | + """ | |
936 | + p = M.Project.query.get(shortname='test') | |
937 | + p.notifications_disabled = True | |
938 | + ThreadLocalORMSession.flush_all() | |
939 | + self._set_options() | |
940 | + self.new_ticket(summary='test') | |
941 | + assert send_simple.call_count == 0, send_simple.call_count | |
942 | + | |
915 | 943 | class TestCustomUserField(TrackerTestController): |
916 | 944 | def setUp(self): |
917 | 945 | super(TestCustomUserField, self).setUp() |
@@ -441,6 +441,14 @@ class RootController(BaseController): | ||
441 | 441 | def update_milestones(self, field_name=None, milestones=None, **kw): |
442 | 442 | require_access(c.app, 'configure') |
443 | 443 | update_counts = False |
444 | + # If the default milestone field doesn't exist, create it. | |
445 | + # TODO: This is a temporary fix for migrated projects, until we make | |
446 | + # the Edit Milestones page capable of editing any/all milestone fields | |
447 | + # instead of just the default "_milestone" field. | |
448 | + if field_name == '_milestone' and \ | |
449 | + field_name not in c.app.globals.milestone_fields: | |
450 | + c.app.globals.custom_fields.append(dict(name='_milestone', | |
451 | + label='Milestone', type='milestone', milestones=[])) | |
444 | 452 | for fld in c.app.globals.milestone_fields: |
445 | 453 | if fld.name == field_name: |
446 | 454 | for new in milestones: |