Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
bug 798529 - non-blank milestone names, r=Pike
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Oct 5, 2012
1 parent 69164db commit 5f7985f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
46 changes: 37 additions & 9 deletions apps/shipping/tests/test_release.py
Expand Up @@ -58,15 +58,6 @@ def test_create_milestones(self):
# should fail because there's no "code"
eq_(response.status_code, 400)

no_name_data = {
'av': 'fx13',
'code-fx13': 'fx_beta_b6',
'yada': 'yada'
}
response = self.client.post(url, no_name_data)
# should fail because there's no "name"
eq_(response.status_code, 400)

# proper input and matching AppVersion
response = self.client.post(url, new_milestones)
# redirecting means it worked
Expand All @@ -80,3 +71,40 @@ def test_create_milestones(self):
# don't try to do it again
response = self.client.post(url, new_milestones)
eq_(response.status_code, 400)

def test_create_milestone_with_blank_name(self):
"""proves that we solved
https://bugzilla.mozilla.org/show_bug.cgi?id=798529
"""
url = reverse('shipping.views.release.create_milestones')

admin = User.objects.create_user(
'admin',
'admin@example.com',
'secret'
)
admin.is_superuser = True
admin.save()
self.client.login(username='admin', password='secret')

app = Application.objects.create(
name='Firefox',
code='fx',
)
AppVersion.objects.create(
app=app,
version='13',
code='fx13',
)

# Send the special POST variables
new_milestones = {
'av': 'fx13',
'code-fx13': 'fx_beta_b6',
'name-fx13': ''
}
response = self.client.post(url, new_milestones)
# redirecting means it worked
eq_(response.status_code, 302)

ok_(Milestone.objects.filter(name=''))
6 changes: 3 additions & 3 deletions apps/shipping/views/release.py
Expand Up @@ -183,9 +183,9 @@ def create_milestones(request):
if not request.POST.get('code-%s' % av):
return HttpResponseBadRequest("'code' not in posted details")
new_miles[av]['code'] = request.POST['code-%s' % av]
if not request.POST.get('name-%s' % av):
return HttpResponseBadRequest("'name' not in posted details")
new_miles[av]['name'] = request.POST['name-%s' % av]
# name can be blank
# see https://bugzilla.mozilla.org/show_bug.cgi?id=798529
new_miles[av]['name'] = request.POST.get('name-%s' % av, '')

# first, let's make sure all data is OK, and then create stuff
for av, details in new_miles.iteritems():
Expand Down

0 comments on commit 5f7985f

Please sign in to comment.