summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-10-07 16:09:28 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2014-10-07 21:12:18 +0200
commit23b4a2e72118afeb691fa92891ca79cbc85b9c4f (patch)
tree7d9e6c9b858b4a5177e7ff17d2770bd828674ff8 /app
parentbbc52b000008c9020d2a38dafc09ff3341a69cae (diff)
downloadgitlab-ce-23b4a2e72118afeb691fa92891ca79cbc85b9c4f.tar.gz
Factor issue and merge request services
Diffstat (limited to 'app')
-rw-r--r--app/services/issuable_base_service.rb13
-rw-r--r--app/services/issues/base_service.rb10
-rw-r--r--app/services/merge_requests/base_service.rb12
3 files changed, 15 insertions, 20 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
new file mode 100644
index 00000000000..e3371ec3c1b
--- /dev/null
+++ b/app/services/issuable_base_service.rb
@@ -0,0 +1,13 @@
+class IssuableBaseService < BaseService
+ private
+
+ def create_assignee_note(issuable)
+ Note.create_assignee_change_note(
+ issuable, issuable.project, current_user, issuable.assignee)
+ end
+
+ def create_milestone_note(issuable)
+ Note.create_milestone_change_note(
+ issuable, issuable.project, current_user, issuable.milestone)
+ end
+end
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index 71b9ffc3489..41948f226a6 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -1,21 +1,13 @@
module Issues
- class BaseService < ::BaseService
+ class BaseService < ::IssuableBaseService
private
- def create_assignee_note(issue)
- Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee)
- end
-
def execute_hooks(issue, action = 'open')
issue_data = issue.to_hook_data
issue_url = Gitlab::UrlBuilder.new(:issue).build(issue.id)
issue_data[:object_attributes].merge!(url: issue_url, action: action)
issue.project.execute_hooks(issue_data, :issue_hooks)
end
-
- def create_milestone_note(issue)
- Note.create_milestone_change_note(issue, issue.project, current_user, issue.milestone)
- end
end
end
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb
index 2907f3587da..694994001b0 100644
--- a/app/services/merge_requests/base_service.rb
+++ b/app/services/merge_requests/base_service.rb
@@ -1,11 +1,5 @@
module MergeRequests
- class BaseService < ::BaseService
-
- private
-
- def create_assignee_note(merge_request)
- Note.create_assignee_change_note(merge_request, merge_request.project, current_user, merge_request.assignee)
- end
+ class BaseService < ::IssuableBaseService
def create_note(merge_request)
Note.create_status_change_note(merge_request, merge_request.target_project, current_user, merge_request.state, nil)
@@ -16,9 +10,5 @@ module MergeRequests
merge_request.project.execute_hooks(merge_request.to_hook_data, :merge_request_hooks)
end
end
-
- def create_milestone_note(merge_request)
- Note.create_milestone_change_note(merge_request, merge_request.project, current_user, merge_request.milestone)
- end
end
end