summaryrefslogtreecommitdiff
path: root/lib/gitlab/data_builder/push.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-08-27 14:43:42 -0700
committerStan Hu <stanhu@gmail.com>2017-08-27 15:50:20 -0700
commit1e53f40c25a87a285ce6f35b5ae1717fe87477ae (patch)
tree6f1c817fcbe72e1662916cc6378b81639d271f8a /lib/gitlab/data_builder/push.rb
parent2be34630623711fc20ef8c101b5cef688f207cc1 (diff)
downloadgitlab-ce-1e53f40c25a87a285ce6f35b5ae1717fe87477ae.tar.gz
Simplify system hook testing and guarantee test will firesh-simplify-system-hook-testing
The change in !11728 would cause an arbitrary project to be chosen to test system hooks, and it's likely that the project would not have any commits or relevant commits to test the hook. This would prevent admins from verifying that the hook fired. Instead of trying to create a representative hook dynamically, just send static data to guarantee the hook will actually be tested. Closes #37067
Diffstat (limited to 'lib/gitlab/data_builder/push.rb')
-rw-r--r--lib/gitlab/data_builder/push.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb
index 5c5f507d44d..4ab5b3455a5 100644
--- a/lib/gitlab/data_builder/push.rb
+++ b/lib/gitlab/data_builder/push.rb
@@ -3,6 +3,35 @@ module Gitlab
module Push
extend self
+ SAMPLE_DATA =
+ {
+ object_kind: "push",
+ event_name: "push",
+ before: "95790bf891e76fee5e1747ab589903a6a1f80f22",
+ after: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
+ ref: "refs/heads/master",
+ checkout_sha: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
+ message: "Hello World",
+ user_id: 4,
+ user_name: "John Smith",
+ user_email: "john@example.com",
+ user_avatar: "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
+ project_id: 15,
+ commits: [
+ {
+ id: "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
+ message: "Add simple search to projects in public area",
+ timestamp: "2013-05-13T18:18:08+00:00",
+ url: "https://test.example.com/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428",
+ author: {
+ name: "Test User",
+ email: "test@example.com"
+ }
+ }
+ ],
+ total_commits_count: 1
+ }.freeze
+
# Produce a hash of post-receive data
#
# data = {
@@ -74,6 +103,10 @@ module Gitlab
build(project, user, commits.last&.id, commits.first&.id, ref, commits)
end
+ def sample_data
+ SAMPLE_DATA
+ end
+
private
def checkout_sha(repository, newrev, ref)