diff options
Diffstat (limited to 'app/services/concerns/integrations/project_test_data.rb')
-rw-r--r-- | app/services/concerns/integrations/project_test_data.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/app/services/concerns/integrations/project_test_data.rb b/app/services/concerns/integrations/project_test_data.rb index 72c12cfb394..57bcba98b49 100644 --- a/app/services/concerns/integrations/project_test_data.rb +++ b/app/services/concerns/integrations/project_test_data.rb @@ -9,35 +9,40 @@ module Integrations end def note_events_data - note = project.notes.first + note = NotesFinder.new(current_user, project: project, target: project).execute.reorder(nil).last # rubocop: disable CodeReuse/ActiveRecord + 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 + 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? issue.to_hook_data(current_user) end def merge_requests_events_data - merge_request = project.merge_requests.first + 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? merge_request.to_hook_data(current_user) end def job_events_data - build = project.builds.first + 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? Gitlab::DataBuilder::Build.build(build) end def pipeline_events_data - pipeline = project.ci_pipelines.newest_first.first + 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? Gitlab::DataBuilder::Pipeline.build(pipeline) @@ -45,6 +50,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 @@ -53,14 +59,16 @@ module Integrations end def deployment_events_data - deployment = project.deployments.first + 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? Gitlab::DataBuilder::Deployment.build(deployment) end def releases_events_data - release = project.releases.first + 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? release.to_hook_data('create') |