summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-05-19 16:27:09 +0000
committerRobert Speicher <robert@gitlab.com>2016-05-19 16:27:09 +0000
commitbbf0a04f5ea1600a65feeded6bf3e8839d600ff6 (patch)
tree5782755d8fd7781f3705bf512ac39d5c72cf34ea /app/services
parent52846d4b7fa49a8b29ba85dbcf16ff95f75e8619 (diff)
parent0698113cabe68f23ac38d7b2fde6c5cb7e5bec4f (diff)
downloadgitlab-ce-bbf0a04f5ea1600a65feeded6bf3e8839d600ff6.tar.gz
Merge branch 'mooreniemi/gitlab-ce-issue_15236' into 'master'
Changing the confidentiality of an issue now creates a new system note Closes #15236. See merge request !4189
Diffstat (limited to 'app/services')
-rw-r--r--app/services/issues/update_service.rb10
-rw-r--r--app/services/system_note_service.rb18
2 files changed, 26 insertions, 2 deletions
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index 3563cbaa997..c7d406cc331 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -24,6 +24,10 @@ module Issues
todo_service.reassigned_issue(issue, current_user)
end
+ if issue.previous_changes.include?('confidential')
+ create_confidentiality_note(issue)
+ end
+
added_labels = issue.labels - old_labels
if added_labels.present?
notification_service.relabeled_issue(issue, added_labels, current_user)
@@ -37,5 +41,11 @@ module Issues
def close_service
Issues::CloseService
end
+
+ private
+
+ def create_confidentiality_note(issue)
+ SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user)
+ end
end
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 4bdb1b0c074..972f8b2012d 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -169,12 +169,26 @@ class SystemNoteService
#
# Returns the created Note object
def self.change_title(noteable, project, author, old_title)
- return unless noteable.respond_to?(:title)
-
body = "Title changed from **#{old_title}** to **#{noteable.title}**"
create_note(noteable: noteable, project: project, author: author, note: body)
end
+ # Called when the confidentiality changes
+ #
+ # issue - Issue object
+ # project - Project owning the issue
+ # author - User performing the change
+ #
+ # Example Note text:
+ #
+ # "Made the issue confidential"
+ #
+ # Returns the created Note object
+ def self.change_issue_confidentiality(issue, project, author)
+ body = issue.confidential ? 'Made the issue confidential' : 'Made the issue visible'
+ create_note(noteable: issue, project: project, author: author, note: body)
+ end
+
# Called when a branch in Noteable is changed
#
# noteable - Noteable object