diff options
author | Alexander Randa <randa.alex@gmail.com> | 2017-07-20 15:12:06 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-20 15:12:06 +0000 |
commit | e0ab5618a0998175df9f90c95ebd35d7afa01db7 (patch) | |
tree | 91cfff5c3c9f6a118d69df5e2816b7461ce2ccc5 /app/services/test_hooks/system_service.rb | |
parent | 020b6a0be06614815d96854084f3dcafeefcf0b7 (diff) | |
download | gitlab-ce-e0ab5618a0998175df9f90c95ebd35d7afa01db7.tar.gz |
Wrong data type when testing webhooks
Diffstat (limited to 'app/services/test_hooks/system_service.rb')
-rw-r--r-- | app/services/test_hooks/system_service.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/services/test_hooks/system_service.rb b/app/services/test_hooks/system_service.rb new file mode 100644 index 00000000000..76c3c19bd74 --- /dev/null +++ b/app/services/test_hooks/system_service.rb @@ -0,0 +1,48 @@ +module TestHooks + class SystemService < TestHooks::BaseService + private + + def project + @project ||= begin + project = Project.first + + throw(:validation_error, 'Ensure that at least one project exists.') unless project + + project + end + end + + def push_events_data + if project.empty_repo? + throw(:validation_error, "Ensure project \"#{project.human_name}\" has commits.") + end + + Gitlab::DataBuilder::Push.build_sample(project, current_user) + end + + def tag_push_events_data + if project.repository.tags.empty? + throw(:validation_error, "Ensure project \"#{project.human_name}\" has tags.") + end + + Gitlab::DataBuilder::Push.build_sample(project, current_user) + end + + def repository_update_events_data + commit = project.commit + ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}" + + unless commit + throw(:validation_error, "Ensure project \"#{project.human_name}\" has commits.") + end + + change = Gitlab::DataBuilder::Repository.single_change( + commit.parent_id || Gitlab::Git::BLANK_SHA, + commit.id, + ref + ) + + Gitlab::DataBuilder::Repository.update(project, current_user, [change], [ref]) + end + end +end |