diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 13:38:35 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 13:38:35 +0300 |
commit | cfd9fd30d60c5a880785acda27e9f3d55b17e4ef (patch) | |
tree | d37dd2c0e2243e6c75f443861bc7568bcd8a78a2 /app/services/issues | |
parent | 3b0510a7c124a8511966ad4785757bd4d78998ac (diff) | |
download | gitlab-ce-cfd9fd30d60c5a880785acda27e9f3d55b17e4ef.tar.gz |
Move code for issue creation to service.
The goal of suych refactoring is to get rid of observers.
Its much easier to test and code when object creation and all other
related actions done in one class instead of splited across observers,
callbacks etc.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services/issues')
-rw-r--r-- | app/services/issues/create_service.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb new file mode 100644 index 00000000000..37f440fc40e --- /dev/null +++ b/app/services/issues/create_service.rb @@ -0,0 +1,23 @@ +module Issues + class CreateService < BaseService + def execute + issue = project.issues.new(params) + issue.author = current_user + + if issue.save + notification_service.new_issue(issue, current_user) + event_service.open_issue(issue, current_user) + issue.create_cross_references!(issue.project, current_user) + execute_hooks(issue) + end + + issue + end + + private + + def execute_hooks(issue) + issue.project.execute_hooks(issue.to_hook_data, :issue_hooks) + end + end +end |