Move #create_confidentiality_note to Issues::UpdateService
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
483c034b86
commit
0698113cab
|
@ -36,12 +36,6 @@ class IssuableBaseService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def create_confidentiality_note(issuable)
|
||||
SystemNoteService.change_confidentiality(
|
||||
issuable, issuable.project, current_user
|
||||
)
|
||||
end
|
||||
|
||||
def filter_params(issuable_ability_name = :issue)
|
||||
filter_assignee
|
||||
filter_milestone
|
||||
|
|
|
@ -10,7 +10,7 @@ module Issues
|
|||
end
|
||||
|
||||
if issue.previous_changes.include?('title') ||
|
||||
issue.previous_changes.include?('description')
|
||||
issue.previous_changes.include?('description')
|
||||
todo_service.update_issue(issue, current_user)
|
||||
end
|
||||
|
||||
|
@ -41,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,29 +169,24 @@ 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
|
||||
#
|
||||
# noteable - Noteable object that responds to 'confidential'
|
||||
# project - Project owning noteable
|
||||
# author - User performing the change
|
||||
# issue - Issue object
|
||||
# project - Project owning the issue
|
||||
# author - User performing the change
|
||||
#
|
||||
# Example Note text:
|
||||
#
|
||||
# "Marked as confidential"
|
||||
# "Made the issue confidential"
|
||||
#
|
||||
# Returns the created Note object
|
||||
def self.change_confidentiality(noteable, project, author)
|
||||
return unless noteable.respond_to?(:confidential)
|
||||
|
||||
confidentiality_status = noteable.confidential ? "confidential" : "not confidential"
|
||||
body = "Marked as #{confidentiality_status}"
|
||||
create_note(noteable: noteable, project: project, author: author, note: body)
|
||||
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
|
||||
|
|
|
@ -82,10 +82,10 @@ describe Issues::UpdateService, services: true do
|
|||
end
|
||||
|
||||
it 'creates system note about confidentiality change' do
|
||||
note = find_note('Marked as confidential')
|
||||
note = find_note('Made the issue confidential')
|
||||
|
||||
expect(note).not_to be_nil
|
||||
expect(note.note).to eq 'Marked as confidential'
|
||||
expect(note.note).to eq 'Made the issue confidential'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -244,24 +244,16 @@ describe SystemNoteService, services: true do
|
|||
to eq "Title changed from **Old title** to **#{noteable.title}**"
|
||||
end
|
||||
end
|
||||
|
||||
context 'when noteable does not respond to `title' do
|
||||
let(:noteable) { double('noteable') }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.change_confidentiality' do
|
||||
subject { described_class.change_confidentiality(noteable, project, author) }
|
||||
describe '.change_issue_confidentiality' do
|
||||
subject { described_class.change_issue_confidentiality(noteable, project, author) }
|
||||
|
||||
context 'when noteable responds to `confidential`' do
|
||||
it_behaves_like 'a system note'
|
||||
|
||||
it 'sets the note text' do
|
||||
expect(subject.note).to eq "Marked as not confidential"
|
||||
expect(subject.note).to eq 'Made the issue visible'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue