2016-01-28 13:04:24 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Notes::PostProcessService do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-01-28 13:04:24 -05:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2016-07-11 18:12:31 -04:00
|
|
|
describe '#execute' do
|
2016-01-28 13:04:24 -05:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2016-01-28 13:04:24 -05:00
|
|
|
note_opts = {
|
|
|
|
note: 'Awesome comment',
|
|
|
|
noteable_type: 'Issue',
|
|
|
|
noteable_id: issue.id
|
|
|
|
}
|
|
|
|
|
|
|
|
@note = Notes::CreateService.new(project, user, note_opts).execute
|
|
|
|
end
|
|
|
|
|
2016-01-28 13:23:37 -05:00
|
|
|
it do
|
2016-01-28 13:04:24 -05:00
|
|
|
expect(project).to receive(:execute_hooks)
|
|
|
|
expect(project).to receive(:execute_services)
|
2016-02-18 18:53:22 -05:00
|
|
|
|
2017-07-25 13:09:00 -04:00
|
|
|
described_class.new(@note).execute
|
2016-01-28 13:23:37 -05:00
|
|
|
end
|
2018-04-03 07:00:33 -04:00
|
|
|
|
|
|
|
context 'with a confidential issue' do
|
|
|
|
let(:issue) { create(:issue, :confidential, project: project) }
|
|
|
|
|
|
|
|
it "doesn't call note hooks/services" do
|
|
|
|
expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks)
|
|
|
|
expect(project).not_to receive(:execute_services).with(anything, :note_hooks)
|
|
|
|
|
|
|
|
described_class.new(@note).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
it "calls confidential-note hooks/services" do
|
|
|
|
expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks)
|
|
|
|
expect(project).to receive(:execute_services).with(anything, :confidential_note_hooks)
|
|
|
|
|
|
|
|
described_class.new(@note).execute
|
|
|
|
end
|
|
|
|
end
|
2016-01-28 13:04:24 -05:00
|
|
|
end
|
|
|
|
end
|