• Tan Le's avatar
    Extract project push rule to service class · af0cc1f3
    Tan Le authored
    Push rules can be treated as a type of settings, such as
    application_settings, project_settings, etc. There must be only one for
    a given project. Therefore, it would be better to just expose the update
    interface and let the creation handled behind the scene.
    
    This commit extracts project push rule create and update logic to
    a dedicated service class. This change allows to centralize auditing
    and logging of actions from Project Push Rule controller and API.
    
    The POST and PUT API can handle both create and update without raising
    `unprocessable_entity` and `not_found` error respectively. Since the
    user can only manage push rule via project id and they can only ever
    create one, this change reduces coordinating POST request before PUT
    request.
    af0cc1f3
project_push_rule_spec.rb 11.8 KB