diff --git a/awx/api/serializers.py b/awx/api/serializers.py index b984ba2a90..b80f5b201a 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1623,7 +1623,7 @@ class JobOptionsSerializer(BaseSerializer): return res def _summary_field_labels(self, obj): - return [{'id': x.id, 'name': x.name} for x in obj.labels.all().order_by('-name')[:10]] + return [{'id': x.id, 'name': x.name} for x in obj.labels.all().order_by('name')[:10]] def get_summary_fields(self, obj): res = super(JobOptionsSerializer, self).get_summary_fields(obj) diff --git a/awx/main/tests/unit/api/test_serializers.py b/awx/main/tests/unit/api/test_serializers.py index 50e6322d1d..52d2317fa9 100644 --- a/awx/main/tests/unit/api/test_serializers.py +++ b/awx/main/tests/unit/api/test_serializers.py @@ -146,7 +146,7 @@ class TestJobOptionsSerializerGetSummaryFields(GetSummaryFieldsMixin): serializer = JobOptionsSerializer() summary_labels = serializer._summary_field_labels(job_template) - job_template.labels.all.order_by.assert_called_with('-name') + job_template.labels.all.order_by.assert_called_with('name') assert len(summary_labels) == 10 assert summary_labels == [{'id': x.id, 'name': x.name} for x in labels[:10]]