bodhi/controllers.py | 7 ++++++
bodhi/tests/test_controllers.py | 41 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
New commits:
commit 17c90317fe39749bb800fb451086ee373e756444
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Oct 8 17:35:50 2010 -0400
Fix a bug with editing updates and replacing builds with newer versions.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 2128d3c..88bde43 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -718,6 +718,13 @@ class Root(controllers.RootController):
# and bring the update back to a pending state
edited.unpush()
+ # Remove the appropriate builds
+ for build in removed_builds:
+ b = PackageBuild.byNvr(build)
+ edited.removePackageBuild(b)
+ if len(b.updates) == 0:
+ b.destroySelf()
+
# Refresh the tags for these builds
for build in edited.builds:
if build.nvr in buildinfo:
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index 0865933..fb69a6d 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -2633,3 +2633,44 @@ class TestControllers(testutil.DBTest):
log = testutil.get_log()
update = PackageUpdate.byTitle(params['builds'])
assert update.request == 'stable', log
+
+ def test_replace_build_with_newer(self):
+ session = login()
+ create_release()
+ params = {
+ 'builds' : 'TurboGears-1.0.8-1.fc7',
+ 'release' : 'Fedora 7',
+ 'type_' : 'security',
+ 'bugs' : '',
+ 'notes' : 'foobar',
+ 'request' : 'Stable',
+ 'autokarma' : True,
+ 'stable_karma' : 5,
+ 'unstable_karma' : -5
+ }
+ self.save_update(params, session)
+
+ # Add another build, for a different release
+ params = {
+ 'builds' : 'TurboGears-1.0.8-1.fc7.1',
+ 'release' : 'Fedora 7',
+ 'type_' : 'bugfix',
+ 'cves' : '',
+ 'bugs' : '',
+ 'notes' : '',
+ 'edited' : 'TurboGears-1.0.8-1.fc7',
+ }
+
+ testutil.capture_log(['bodhi.controllers', 'bodhi.util',
'bodhi.model'])
+ self.save_update(params, session)
+ logs = testutil.get_log()
+
+ up = PackageUpdate.byTitle('TurboGears-1.0.8-1.fc7.1')
+ assert up.comments[-1].text == 'guest has edited this update. New build(s):
TurboGears-1.0.8-1.fc7.1. Removed build(s): TurboGears-1.0.8-1.fc7.'
+ assert len(up.builds) == 1, logs
+ try:
+ PackageBuild.byNvr('TurboGears-1.0.8-1.fc7')
+ assert False, "Removed build not deleted from database!"
+ except SQLObjectNotFound:
+ pass
+
Show replies by date