Browse files

fixed bug with creating new suite

  • Loading branch information...
1 parent 912c379 commit c0b3bb9ba39a31e36ce5694f9137b676f195f951 @camd camd committed Mar 25, 2013
Showing with 30 additions and 1 deletion.
  1. +1 −1 moztrap/view/manage/suites/forms.py
  2. +29 −0 tests/view/manage/suites/test_forms.py
View
2 moztrap/view/manage/suites/forms.py
@@ -61,7 +61,7 @@ def clean_cases(self):
clean_cases.append(case)
# if number is different, then add this to changed data
- if (self.initial["cases"] != self.cleaned_data["cases"] or
+ if (("cases" in self.initial and self.initial["cases"] != self.cleaned_data["cases"]) or
len(self.cleaned_data["cases"]) is not len(clean_cases)):
self.changed_data.append("cases")
View
29 tests/view/manage/suites/test_forms.py
@@ -150,6 +150,35 @@ def test_edit_cases(self):
self.assertEqual(set(suite.cases.all()), set([c]))
+ def test_edit_cases_order_only(self):
+ """Can edit cases of a suite."""
+ s = self.F.SuiteFactory.create()
+ c1 = self.F.CaseFactory.create(product=s.product)
+ c2 = self.F.CaseFactory.create(product=s.product)
+ self.F.SuiteCaseFactory.create(suite=s, case=c1, order=0)
+ self.F.SuiteCaseFactory.create(suite=s, case=c2, order=1)
+
+ f = self.form(
+ {
+ "product": str(s.product.id),
+ "name": s.name,
+ "description": s.description,
+ "status": s.status,
+ "cases": [str(c2.id), str(c1.id)],
+ "cc_version": str(s.cc_version),
+ },
+ instance=s,
+ )
+
+ self.assertTrue(f.is_valid())
+ suite = f.save()
+
+ self.assertEqual(
+ list(suite.cases.all().order_by("suitecases__order")),
+ [c2, c1],
+ )
+
+
def test_remove_dup_cases(self):
"""Can edit cases of a suite."""
s = self.F.SuiteFactory.create()

0 comments on commit c0b3bb9

Please sign in to comment.