Split status and confidentiality action
This commit is contained in:
parent
b57ed57f6b
commit
d67d43d1b6
3 changed files with 36 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
|||
class SystemNoteMetadata < ActiveRecord::Base
|
||||
ICON_TYPES = %w[
|
||||
commit merge confidentiality status label assignee cross_reference
|
||||
title time_tracking branch milestone discussion task moved
|
||||
commit merge confidential visible label assignee cross_reference
|
||||
title time_tracking branch milestone discussion task moved opened closed merged
|
||||
].freeze
|
||||
|
||||
validates :note, presence: true
|
||||
|
|
|
@ -183,7 +183,9 @@ module SystemNoteService
|
|||
body = status.dup
|
||||
body << " via #{source.gfm_reference(project)}" if source
|
||||
|
||||
create_note(NoteSummary.new(noteable, project, author, body, action: 'status'))
|
||||
action = status == 'reopened' ? 'opened' : status
|
||||
|
||||
create_note(NoteSummary.new(noteable, project, author, body, action: action))
|
||||
end
|
||||
|
||||
# Called when 'merge when pipeline succeeds' is executed
|
||||
|
@ -273,9 +275,15 @@ module SystemNoteService
|
|||
#
|
||||
# Returns the created Note object
|
||||
def change_issue_confidentiality(issue, project, author)
|
||||
body = issue.confidential ? 'made the issue confidential' : 'made the issue visible to everyone'
|
||||
if issue.confidential
|
||||
body = 'made the issue confidential'
|
||||
action = 'confidential'
|
||||
else
|
||||
body = 'made the issue visible to everyone'
|
||||
action = 'visible'
|
||||
end
|
||||
|
||||
create_note(NoteSummary.new(issue, project, author, body, action: 'confidentiality'))
|
||||
create_note(NoteSummary.new(issue, project, author, body, action: action))
|
||||
end
|
||||
|
||||
# Called when a branch in Noteable is changed
|
||||
|
|
|
@ -221,26 +221,23 @@ describe SystemNoteService, services: true do
|
|||
describe '.change_status' do
|
||||
subject { described_class.change_status(noteable, project, author, status, source) }
|
||||
|
||||
let(:status) { 'new_status' }
|
||||
let(:source) { nil }
|
||||
context 'with status reopened' do
|
||||
let(:status) { 'reopened' }
|
||||
let(:source) { nil }
|
||||
|
||||
it_behaves_like 'a system note' do
|
||||
let(:action) { 'status' }
|
||||
it_behaves_like 'a system note' do
|
||||
let(:action) { 'opened' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a source' do
|
||||
let(:status) { 'opened' }
|
||||
let(:source) { double('commit', gfm_reference: 'commit 123456') }
|
||||
|
||||
it 'sets the note text' do
|
||||
expect(subject.note).to eq "#{status} via commit 123456"
|
||||
end
|
||||
end
|
||||
|
||||
context 'without a source' do
|
||||
it 'sets the note text' do
|
||||
expect(subject.note).to eq status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.merge_when_pipeline_succeeds' do
|
||||
|
@ -298,9 +295,23 @@ describe SystemNoteService, services: true do
|
|||
describe '.change_issue_confidentiality' do
|
||||
subject { described_class.change_issue_confidentiality(noteable, project, author) }
|
||||
|
||||
context 'when noteable responds to `confidential`' do
|
||||
context 'issue has been made confidential' do
|
||||
before do
|
||||
noteable.update_attribute(:confidential, true)
|
||||
end
|
||||
|
||||
it_behaves_like 'a system note' do
|
||||
let(:action) { 'confidentiality' }
|
||||
let(:action) { 'confidential' }
|
||||
end
|
||||
|
||||
it 'sets the note text' do
|
||||
expect(subject.note).to eq 'made the issue confidential'
|
||||
end
|
||||
end
|
||||
|
||||
context 'issue has been made visible' do
|
||||
it_behaves_like 'a system note' do
|
||||
let(:action) { 'visible' }
|
||||
end
|
||||
|
||||
it 'sets the note text' do
|
||||
|
|
Loading…
Reference in a new issue