Commits

Remy Blank committed d4e7cf2

0.11.7dev: Fixed an issue where creating a new milestone with the same name as an existing one, then changing the name would rename the existing milestone instead of creating a new one.

Patch by Niels Reedijk, thanks! Closes #8816.

  • Participants
  • Parent commits 12aa60d
  • Branches 0.11-stable

Comments (0)

Files changed (2)

File trac/ticket/roadmap.py

         old_name = milestone.name
         new_name = req.args.get('name')
         
-        milestone.name = new_name
         milestone.description = req.args.get('description', '')
 
         due = req.args.get('duedate', '')
                     warn(_('Milestone "%(name)s" already exists, please '
                            'choose another name', name=new_name))
                 except ResourceNotFound:
-                    pass
+                    milestone.name = new_name
         else:
             warn(_('You must provide a name for the milestone.'))
 

File trac/ticket/tests/functional.py

         tc.notfind('anonymous')
 
 
+class RegressionTestTicket8861(FunctionalTwillTestCaseSetup):
+    def runTest(self):
+        """Test for regression of http://trac.edgewall.org/ticket/8816
+        When creating a milestone with an already existing name, you get
+        a warning. After changing the name you will find that the original
+        milestone with that name is renamed instead of a new one being
+        created."""
+        name = "8861Milestone"
+        self._tester.create_milestone(name)
+        tc.go(self._tester.url + "/milestone?action=new")
+        tc.formvalue('edit', 'name', name)
+        tc.submit('Add milestone')
+        tc.find('Milestone "%s" already exists' % name)
+        tc.formvalue('edit', 'name', name + '__')
+        tc.submit('Add milestone')
+        tc.go(self._tester.url + "/roadmap")
+        tc.find('Milestone: <em>%s</em>' % name)
+        tc.find('Milestone: <em>%s</em>' % (name + '__'))
+
+
 def functionalSuite(suite=None):
     if not suite:
         import trac.tests.functional.testcases
     suite.addTest(RegressionTestTicket6912a())
     suite.addTest(RegressionTestTicket6912b())
     suite.addTest(RegressionTestTicket8247())
+    suite.addTest(RegressionTestTicket8861())
 
     return suite