summaryrefslogtreecommitdiff
path: root/app/services/test_hooks
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-07 13:29:12 +0200
committerRémy Coutable <remy@rymai.me>2017-09-07 17:40:32 +0200
commit9e2015752848c908d99a26daf3c0e6e968b95f68 (patch)
treeb41f1e781d346867a8198cc139de73c50ec77049 /app/services/test_hooks
parentd2cafa894a9e15e3f8827029ead064543d2a3b19 (diff)
downloadgitlab-ce-9e2015752848c908d99a26daf3c0e6e968b95f68.tar.gz
Fix a wrong `X-Gitlab-Event` header when testing webhooks37288-fix-wrong-header-when-testing-webhook
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/services/test_hooks')
-rw-r--r--app/services/test_hooks/base_service.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/services/test_hooks/base_service.rb b/app/services/test_hooks/base_service.rb
index 4abd2c44b2f..20d90504bd2 100644
--- a/app/services/test_hooks/base_service.rb
+++ b/app/services/test_hooks/base_service.rb
@@ -9,18 +9,17 @@ module TestHooks
end
def execute
+ trigger_key = hook.class::TRIGGERS.key(trigger.to_sym)
trigger_data_method = "#{trigger}_data"
- if !self.respond_to?(trigger_data_method, true) ||
- !hook.class::TRIGGERS.value?(trigger.to_sym)
-
+ if trigger_key.nil? || !self.respond_to?(trigger_data_method, true)
return error('Testing not available for this hook')
end
error_message = catch(:validation_error) do
sample_data = self.__send__(trigger_data_method) # rubocop:disable GitlabSecurity/PublicSend
- return hook.execute(sample_data, trigger)
+ return hook.execute(sample_data, trigger_key)
end
error(error_message)