diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/services/concerns/integrations/project_test_data.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/services/concerns/integrations/project_test_data.rb')
-rw-r--r-- | app/services/concerns/integrations/project_test_data.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/app/services/concerns/integrations/project_test_data.rb b/app/services/concerns/integrations/project_test_data.rb index ae1e1d1e66c..b3427697052 100644 --- a/app/services/concerns/integrations/project_test_data.rb +++ b/app/services/concerns/integrations/project_test_data.rb @@ -2,8 +2,14 @@ module Integrations module ProjectTestData + NoDataError = Class.new(ArgumentError) + private + def no_data_error(msg) + raise NoDataError, msg + end + def push_events_data Gitlab::DataBuilder::Push.build_sample(project, current_user) end @@ -11,7 +17,7 @@ module Integrations def note_events_data note = NotesFinder.new(current_user, project: project, target: project, sort: 'id_desc').execute.first - return { error: s_('TestHooks|Ensure the project has notes.') } unless note.present? + no_data_error(s_('TestHooks|Ensure the project has notes.')) unless note.present? Gitlab::DataBuilder::Note.build(note, current_user) end @@ -19,7 +25,7 @@ module Integrations def issues_events_data issue = IssuesFinder.new(current_user, project_id: project.id, sort: 'created_desc').execute.first - return { error: s_('TestHooks|Ensure the project has issues.') } unless issue.present? + no_data_error(s_('TestHooks|Ensure the project has issues.')) unless issue.present? issue.to_hook_data(current_user) end @@ -27,7 +33,7 @@ module Integrations def merge_requests_events_data merge_request = MergeRequestsFinder.new(current_user, project_id: project.id, sort: 'created_desc').execute.first - return { error: s_('TestHooks|Ensure the project has merge requests.') } unless merge_request.present? + no_data_error(s_('TestHooks|Ensure the project has merge requests.')) unless merge_request.present? merge_request.to_hook_data(current_user) end @@ -35,7 +41,7 @@ module Integrations def job_events_data build = Ci::JobsFinder.new(current_user: current_user, project: project).execute.first - return { error: s_('TestHooks|Ensure the project has CI jobs.') } unless build.present? + no_data_error(s_('TestHooks|Ensure the project has CI jobs.')) unless build.present? Gitlab::DataBuilder::Build.build(build) end @@ -43,7 +49,7 @@ module Integrations def pipeline_events_data pipeline = Ci::PipelinesFinder.new(project, current_user, order_by: 'id', sort: 'desc').execute.first - return { error: s_('TestHooks|Ensure the project has CI pipelines.') } unless pipeline.present? + no_data_error(s_('TestHooks|Ensure the project has CI pipelines.')) unless pipeline.present? Gitlab::DataBuilder::Pipeline.build(pipeline) end @@ -51,9 +57,7 @@ module Integrations 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 + no_data_error(s_('TestHooks|Ensure the wiki is enabled and has pages.')) if !project.wiki_enabled? || page.blank? Gitlab::DataBuilder::WikiPage.build(page, current_user, 'create') end @@ -61,7 +65,7 @@ module Integrations def deployment_events_data deployment = DeploymentsFinder.new(project: project, order_by: 'created_at', sort: 'desc').execute.first - return { error: s_('TestHooks|Ensure the project has deployments.') } unless deployment.present? + no_data_error(s_('TestHooks|Ensure the project has deployments.')) unless deployment.present? Gitlab::DataBuilder::Deployment.build(deployment, deployment.status, Time.current) end @@ -69,7 +73,7 @@ module Integrations def releases_events_data release = ReleasesFinder.new(project, current_user, order_by: :created_at, sort: :desc).execute.first - return { error: s_('TestHooks|Ensure the project has releases.') } unless release.present? + no_data_error(s_('TestHooks|Ensure the project has releases.')) unless release.present? release.to_hook_data('create') end |