From 84cc33412a1b400272ab98e3e48ff30ce405fcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Wed, 26 Aug 2020 10:08:37 +0300 Subject: [PATCH] When copying a check, copy all fields from the "Filtering Rules" dialog --- CHANGELOG.md | 2 +- hc/front/tests/test_copy.py | 11 ++++++++--- hc/front/views.py | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eec8165..4dc51816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. - Handle excessively long email addresses in the signup form - Handle excessively long email addresses in the team member invite form - Don't allow duplicate team memberships -- When copying a check, also copy the "failure keyword" field (#417) +- When copying a check, copy all fields from the "Filtering Rules" dialog (#417) ## v1.16.0 - 2020-08-04 diff --git a/hc/front/tests/test_copy.py b/hc/front/tests/test_copy.py index e9b815dc..7d27e8ca 100644 --- a/hc/front/tests/test_copy.py +++ b/hc/front/tests/test_copy.py @@ -9,6 +9,8 @@ class CopyCheckTestCase(BaseTestCase): self.check.name = "Foo" self.check.subject = "success-keyword" self.check.subject_fail = "failure-keyword" + self.check.methods = "POST" + self.check.manual_resume = True self.check.save() self.copy_url = "/checks/%s/copy/" % self.check.code @@ -17,9 +19,12 @@ class CopyCheckTestCase(BaseTestCase): self.client.login(username="alice@example.org", password="password") r = self.client.post(self.copy_url, follow=True) self.assertContains(r, "This is a brand new check") - self.assertContains(r, "Foo (copy)") - self.assertContains(r, "success-keyword") - self.assertContains(r, "failure-keyword") + + copy = Check.objects.get(name="Foo (copy)") + self.assertEqual(copy.subject, "success-keyword") + self.assertEqual(copy.subject_fail, "failure-keyword") + self.assertEqual(copy.methods, "POST") + self.assertTrue(copy.manual_resume) def test_it_obeys_limit(self): self.profile.check_limit = 0 diff --git a/hc/front/views.py b/hc/front/views.py index 071f9870..1754a0fa 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -592,8 +592,9 @@ def copy(request, code): copied = Check(project=check.project) copied.name = check.name + " (copy)" copied.desc, copied.tags = check.desc, check.tags - copied.subject = check.subject - copied.subject_fail = check.subject_fail + copied.subject, copied.subject_fail = check.subject, check.subject_fail + copied.methods = check.methods + copied.manual_resume = check.manual_resume copied.kind = check.kind copied.timeout, copied.grace = check.timeout, check.grace