summaryrefslogtreecommitdiff
path: root/app/services/test_hooks/system_service.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 /app/services/test_hooks/system_service.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 'app/services/test_hooks/system_service.rb')
-rw-r--r--app/services/test_hooks/system_service.rb37
1 files changed, 3 insertions, 34 deletions
diff --git a/app/services/test_hooks/system_service.rb b/app/services/test_hooks/system_service.rb
index 76c3c19bd74..67552edefc9 100644
--- a/app/services/test_hooks/system_service.rb
+++ b/app/services/test_hooks/system_service.rb
@@ -2,47 +2,16 @@ 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)
+ Gitlab::DataBuilder::Push.sample_data
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)
+ Gitlab::DataBuilder::Push.sample_data
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])
+ Gitlab::DataBuilder::Repository.sample_data
end
end
end