Commit 7763323c authored by Claude Paroz's avatar Claude Paroz

[vertimus] Fix mail not sent to mailing list when committing

parent 5279c0df
......@@ -37,7 +37,7 @@ class TeamsAndRolesTests(TestCase):
self.pcoo.set_password('password')
self.pcoo.save()
self.t = Team(name='fr', description='French', mailing_list='nowhere@example.org')
self.t = Team(name='fr', description='French', mailing_list='french_ml@example.org')
self.t.save()
self.t2 = Team(name='pt', description='Portuguese')
......
......@@ -417,6 +417,7 @@ class Action(ActionAbstract):
# All actions change state except Writing a comment
self.state_db.change_state(self.target_state, self.person)
if self.target_state == StateCommitted:
self.send_mail_new_state(state, (state.language.team.mailing_list,))
# Committed is the last state of the workflow, archive actions
arch_action = self.new_by_name('AA', person=self.person)
arch_action.apply_on(self.state_db)
......@@ -627,8 +628,7 @@ class ActionCI(Action):
# FIXME: somewhere the error should be catched and handled properly
raise Exception(_("The commit failed. The error was: '%s'") % sys.exc_info()[1])
super(ActionCI, self).apply_on(state)
self.send_mail_new_state(state, (state.language.team.mailing_list,))
super(ActionCI, self).apply_on(state) # Mail sent in super
class ActionRC(Action):
name = 'RC'
......@@ -645,10 +645,6 @@ class ActionIC(Action):
class Meta:
proxy = True
def apply(self, state):
super(ActionIC, self).apply_on(state)
self.send_mail_new_state(state, (state.language.team.mailing_list,))
class ActionTR(Action):
name = 'TR'
target_state = StateToReview
......
......@@ -273,19 +273,28 @@ class VertimusTest(TeamsAndRolesTests):
action = Action.new_by_name('UP', person=self.pr, comment="Done.", file=test_file)
action.apply_on(state)
self.assertEquals(len(mail.outbox), 1) # Mail sent to mailing list
mail.outbox = []
file_path = os.path.join(settings.MEDIA_ROOT, action.file.name)
self.assertTrue(os.access(file_path, os.W_OK))
action = Action.new_by_name('TC', person=self.pc, comment="To commit.")
action.apply_on(state)
self.assertEquals(len(mail.outbox), 1) # Mail sent to committers
mail.outbox = []
action = Action.new_by_name('RC', person=self.pc, comment="Reserved commit.")
action.apply_on(state)
action = Action.new_by_name('IC', person=self.pc, comment="Committed.")
action.apply_on(state)
# Mail sent to mailing list
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].recipients(), [self.l.team.mailing_list])
self.assertTrue(u'Commité' in mail.outbox[0].body) # Team is French
self.assertTrue(isinstance(state, StateNone))
self.assertTrue(not os.access(file_path, os.F_OK), "%s not deleted" % file_path)
# Remove test file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment