diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index df71228d0..561c0fc0a 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -78,7 +78,7 @@ class EventRuleSerializer(NetBoxModelSerializer): fields = [ 'id', 'url', 'display', 'content_types', 'name', 'type_create', 'type_update', 'type_delete', 'type_job_start', 'type_job_end', 'enabled', 'conditions', 'action_type', 'action_object_type', - 'action_object_id', 'action_object', 'custom_fields', 'tags', 'created', 'last_updated', + 'action_object_id', 'action_object', 'description', 'custom_fields', 'tags', 'created', 'last_updated', ] @extend_schema_field(OpenApiTypes.OBJECT) diff --git a/netbox/extras/tests/test_api.py b/netbox/extras/tests/test_api.py index 17016d309..7fe9cea85 100644 --- a/netbox/extras/tests/test_api.py +++ b/netbox/extras/tests/test_api.py @@ -72,6 +72,15 @@ class WebhookTest(APIViewTestCases.APIViewTestCase): class EventRuleTest(APIViewTestCases.APIViewTestCase): model = EventRule brief_fields = ['display', 'id', 'name',] + bulk_update_data = { + 'enabled': False, + 'description': 'New description', + } + update_data = { + 'name': 'Event Rule X', + 'enabled': False, + 'description': 'New description', + } @classmethod def setUpTestData(cls): @@ -103,18 +112,14 @@ class EventRuleTest(APIViewTestCases.APIViewTestCase): ) Webhook.objects.bulk_create(webhooks) - def setUp(self): - super().setUp() - - webhooks = Webhook.objects.all() event_rules = ( - EventRule(name='EventRule 1', action_object=webhooks[0]), - EventRule(name='EventRule 2', action_object=webhooks[1]), - EventRule(name='EventRule 3', action_object=webhooks[2]), + EventRule(name='EventRule 1', type_create=True, action_object=webhooks[0]), + EventRule(name='EventRule 2', type_create=True, action_object=webhooks[1]), + EventRule(name='EventRule 3', type_create=True, action_object=webhooks[2]), ) EventRule.objects.bulk_create(event_rules) - self.create_data = [ + cls.create_data = [ { 'name': 'EventRule 4', 'content_types': ['dcim.device', 'dcim.devicetype'],