Merge "When editing an image, correctly set the 'is_public' checkbox."

This commit is contained in:
Jenkins 2012-11-09 01:38:46 +00:00 committed by Gerrit Code Review
commit 220f99e3c7
2 changed files with 23 additions and 1 deletions

View File

@ -94,3 +94,25 @@ class ImageViewTests(test.TestCase):
args=[image.id])
res = self.client.get(url)
self.assertRedirectsNoFollow(res, IMAGES_INDEX_URL)
@test.create_stubs({api: ('image_get',)})
def test_image_update_get(self):
image = self.images.first()
image.disk_format = "ami"
image.is_public = True
api.image_get(IsA(http.HttpRequest), str(image.id)) \
.AndReturn(image)
self.mox.ReplayAll()
res = self.client.get(
reverse('horizon:project:images_and_snapshots:images:update',
args=[image.id]))
self.assertTemplateUsed(res,
'project/images_and_snapshots/images/_update.html')
self.assertEqual(res.context['image'].name, image.name)
# Bug 1076216 - is_public checkbox not being set correctly
self.assertContains(res, "<input type='checkbox' id='id_public'"
" name='public' checked='checked'>",
html=True,
msg_prefix="The is_public checkbox is not checked")

View File

@ -76,7 +76,7 @@ class UpdateView(forms.ModalFormView):
'ramdisk': image.properties.get('ramdisk_id', ''),
'architecture': image.properties.get('architecture', ''),
'disk_format': image.disk_format,
'public': image.is_public == "True"}
'public': image.is_public}
class DetailView(tabs.TabView):