changeset 285:4fabcaf75787

Fix a bug that prevented a build configuration to be renamed after target platforms have been added, and maybe even builds executed.
author cmlenz
date Sat, 15 Oct 2005 07:41:52 +0000
parents ddc93fe34cad
children 6abd43d0cd8a
files bitten/model.py bitten/tests/model.py
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/model.py
+++ b/bitten/model.py
@@ -108,6 +108,11 @@
                        (self.name, self.path, int(self.active or 0),
                         self.recipe, self.min_rev, self.max_rev,
                         self.label, self.description, self._old_name))
+        if self.name != self._old_name:
+            cursor.execute("UPDATE bitten_platform SET config=%s "
+                           "WHERE config=%s", (self.name, self._old_name))
+            cursor.execute("UPDATE bitten_build SET config=%s "
+                           "WHERE config=%s", (self.name, self._old_name))
 
         if handle_ta:
             db.commit()
--- a/bitten/tests/model.py
+++ b/bitten/tests/model.py
@@ -115,6 +115,22 @@
         config.name = None
         self.assertRaises(AssertionError, config.update)
 
+    def test_update_name_with_platform(self):
+        db = self.env.get_db_cnx()
+        cursor = db.cursor()
+        cursor.execute("INSERT INTO bitten_config (name,path,label,active) "
+                       "VALUES (%s,%s,%s,%s)", ('test', 'trunk', 'Test', 0))
+        cursor.execute("INSERT INTO bitten_platform (config,name) "
+                       "VALUES (%s,%s)", ('test', 'NetBSD'))
+
+        config = BuildConfig.fetch(self.env, 'test')
+        config.name = 'foobar'
+        config.update()
+
+        cursor.execute("SELECT config,name FROM bitten_platform")
+        self.assertEqual(('foobar', 'NetBSD'), cursor.fetchone())
+        self.assertEqual(None, cursor.fetchone())
+
     def test_delete(self):
         db = self.env.get_db_cnx()
         cursor = db.cursor()
Copyright (C) 2012-2017 Edgewall Software