mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-12 06:06:05 +10:00
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
This commit is contained in:
@@ -10,6 +10,7 @@ v 8.8.0 (unreleased)
|
||||
- Escape HTML in commit titles in system note messages
|
||||
- Improve multiple branch push performance by memoizing permission checking
|
||||
- Log to application.log when an admin starts and stops impersonating a user
|
||||
- Changing the confidentiality of an issue now creates a new system note (Alex Moore-Niemi)
|
||||
- Updated gitlab_git to 10.1.0
|
||||
- GitAccess#protected_tag? no longer loads all tags just to check if a single one exists
|
||||
- Reduce delay in destroying a project from 1-minute to immediately
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -27,11 +27,6 @@ describe Issues::UpdateService, services: true do
|
||||
end
|
||||
end
|
||||
|
||||
def update_issue(opts)
|
||||
@issue = Issues::UpdateService.new(project, user, opts).execute(issue)
|
||||
@issue.reload
|
||||
end
|
||||
|
||||
context "valid params" do
|
||||
before do
|
||||
opts = {
|
||||
@@ -39,7 +34,8 @@ describe Issues::UpdateService, services: true do
|
||||
description: 'Also please fix',
|
||||
assignee_id: user2.id,
|
||||
state_event: 'close',
|
||||
label_ids: [label.id]
|
||||
label_ids: [label.id],
|
||||
confidential: true
|
||||
}
|
||||
|
||||
perform_enqueued_jobs do
|
||||
@@ -84,6 +80,18 @@ describe Issues::UpdateService, services: true do
|
||||
expect(note).not_to be_nil
|
||||
expect(note.note).to eq 'Title changed from **Old title** to **New title**'
|
||||
end
|
||||
|
||||
it 'creates system note about confidentiality change' do
|
||||
note = find_note('Made the issue confidential')
|
||||
|
||||
expect(note).not_to be_nil
|
||||
expect(note.note).to eq 'Made the issue confidential'
|
||||
end
|
||||
end
|
||||
|
||||
def update_issue(opts)
|
||||
@issue = Issues::UpdateService.new(project, user, opts).execute(issue)
|
||||
@issue.reload
|
||||
end
|
||||
|
||||
context 'todos' do
|
||||
|
||||
@@ -244,12 +244,16 @@ describe SystemNoteService, services: true do
|
||||
to eq "Title changed from **Old title** to **#{noteable.title}**"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when noteable does not respond to `title' do
|
||||
let(:noteable) { double('noteable') }
|
||||
describe '.change_issue_confidentiality' do
|
||||
subject { described_class.change_issue_confidentiality(noteable, project, author) }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
context 'when noteable responds to `confidential`' do
|
||||
it_behaves_like 'a system note'
|
||||
|
||||
it 'sets the note text' do
|
||||
expect(subject.note).to eq 'Made the issue visible'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user