diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/services/concerns/integrations/project_test_data.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/services/concerns/integrations/project_test_data.rb')
-rw-r--r-- | app/services/concerns/integrations/project_test_data.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/app/services/concerns/integrations/project_test_data.rb b/app/services/concerns/integrations/project_test_data.rb new file mode 100644 index 00000000000..4d551430315 --- /dev/null +++ b/app/services/concerns/integrations/project_test_data.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +module Integrations + module ProjectTestData + private + + def push_events_data + Gitlab::DataBuilder::Push.build_sample(project, current_user) + end + + def note_events_data + note = project.notes.first + return { error: s_('TestHooks|Ensure the project has notes.') } unless note.present? + + Gitlab::DataBuilder::Note.build(note, current_user) + end + + def issues_events_data + issue = project.issues.first + return { error: s_('TestHooks|Ensure the project has issues.') } unless issue.present? + + issue.to_hook_data(current_user) + end + + def merge_requests_events_data + merge_request = project.merge_requests.first + return { error: s_('TestHooks|Ensure the project has merge requests.') } unless merge_request.present? + + merge_request.to_hook_data(current_user) + end + + def job_events_data + build = project.builds.first + return { error: s_('TestHooks|Ensure the project has CI jobs.') } unless build.present? + + Gitlab::DataBuilder::Build.build(build) + end + + def pipeline_events_data + pipeline = project.ci_pipelines.newest_first.first + return { error: s_('TestHooks|Ensure the project has CI pipelines.') } unless pipeline.present? + + Gitlab::DataBuilder::Pipeline.build(pipeline) + end + + def wiki_page_events_data + page = project.wiki.list_pages(limit: 1).first + if !project.wiki_enabled? || page.blank? + return { error: s_('TestHooks|Ensure the wiki is enabled and has pages.') } + end + + Gitlab::DataBuilder::WikiPage.build(page, current_user, 'create') + end + + def deployment_events_data + deployment = project.deployments.first + return { error: s_('TestHooks|Ensure the project has deployments.') } unless deployment.present? + + Gitlab::DataBuilder::Deployment.build(deployment) + end + end +end |