debian-mirror-gitlab/spec/services/notes/post_process_service_spec.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-04-02 18:10:28 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Notes::PostProcessService do
let(:project) { create(:project) }
2016-04-02 18:10:28 +05:30
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
2016-08-24 12:49:21 +05:30
describe '#execute' do
2016-04-02 18:10:28 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2016-04-02 18:10:28 +05:30
note_opts = {
note: 'Awesome comment',
noteable_type: 'Issue',
noteable_id: issue.id
}
@note = Notes::CreateService.new(project, user, note_opts).execute
end
it do
expect(project).to receive(:execute_hooks)
expect(project).to receive(:execute_services)
2017-09-10 17:25:29 +05:30
described_class.new(@note).execute
2016-04-02 18:10:28 +05:30
end
2018-04-05 14:03:07 +05:30
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-04-02 18:10:28 +05:30
end
end