Commit 2e97db05 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Make the new repository_update_events configurable in System Hooks UI

parent f6619809
......@@ -60,6 +60,7 @@ class Admin::HooksController < Admin::ApplicationController
class SystemHook < WebHook
scope :repository_update_hooks, -> { where(repository_update_events: true) }
default_value_for :push_events, false
default_value_for :repository_update_events, true
def async_execute(data, hook_name)
Sidekiq::Client.enqueue(SystemHookWorker, id, data, hook_name)
......@@ -18,12 +18,19 @@
or adding ssh key. But you can also enable extra triggers like Push events.
= form.check_box :repository_update_events, class: 'pull-left'
= form.label :repository_update_events, class: 'list-label' do
%strong Repository update events
This url will be triggered when repository is updated
= form.check_box :push_events, class: 'pull-left'
= form.label :push_events, class: 'list-label' do
%strong Push events
This url will be triggered by a push to the repository
This url will be triggered for each branch updated to the repository
= form.check_box :tag_push_events, class: 'pull-left'
......@@ -27,7 +27,7 @@
= link_to 'Remove', admin_hook_path(hook), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-remove btn-sm'
.monospace= hook.url
- %w(push_events tag_push_events issues_events note_events merge_requests_events build_events).each do |trigger|
- %w(push_events tag_push_events issues_events note_events merge_requests_events build_events repository_update_events).each do |trigger|
- if hook.send(trigger)
%span.label.label-gray= trigger.titleize
%span.label.label-gray SSL Verification: #{hook.enable_ssl_verification ? 'enabled' : 'disabled'}
require 'spec_helper'
describe Admin::HooksController do
let(:admin) { create(:admin) }
before do
describe 'POST #create' do
it 'sets all parameters' do
hook_params = {
enable_ssl_verification: true,
push_events: true,
tag_push_events: true,
repository_update_events: true,
token: "TEST TOKEN",
url: "",
post :create, hook: hook_params
expect(response).to have_http_status(302)
expect(SystemHook.all.size).to eq(1)
expect(SystemHook.first).to have_attributes(hook_params)
require "spec_helper"
describe SystemHook, models: true do
context 'default attributes' do
let(:system_hook) { build(:system_hook) }
it 'sets defined default parameters' do
attrs = {
push_events: false,
repository_update_events: true,
enable_ssl_verification: true
expect(system_hook).to have_attributes(attrs)
describe "execute" do
let(:system_hook) { create(:system_hook) }
let(:user) { create(:user) }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment