Project services API doesn't use the correct event names

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Zendesk: https://gitlab.zendesk.com/agent/tickets/83189

Project services specify which events they support. For example, HipChat specifies the following - https://gitlab.com/gitlab-org/gitlab-ce/blob/e4e8e0fc9df9dbd1cc6582ef9932a346e1c376a0/app/models/project_services/hipchat_service.rb#L48-50

The issue is that the supported events use singular style even though some events are actually plural. For example, merge_request 'supported event' actually translates to merge_requests_events attribute (plural). This works on the app side because we pluralize certain event names in https://gitlab.com/gitlab-org/gitlab-ce/blob/e4e8e0fc9df9dbd1cc6582ef9932a346e1c376a0/app/helpers/services_helper.rb#L26.

However, in the API we don't pluralize these - we simply present that using the supported events attribute from the service and append _events - https://gitlab.com/gitlab-org/gitlab-ce/blob/e4e8e0fc9df9dbd1cc6582ef9932a346e1c376a0/lib/api/services.rb#L620-627. This makes it impossible to toggle merge request and other pluralized events via the API.

Possible solutions

My recommendation is to remove the magic and require the service classes to specify the pluralized value to begin with. This simplifies things and makes the code clearer while also reducing the future risk of a regression. We should also add test(s) to ensure that service classes specify valid supported_events.

cc/ @DouweM @jramsay

Edited by 🤖 GitLab Bot 🤖