2016-08-09 11:51:40 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Issues::ReopenService, services: true do
|
2016-08-12 15:05:10 -04:00
|
|
|
let(:project) { create(:empty_project) }
|
|
|
|
let(:issue) { create(:issue, :closed, project: project) }
|
2016-08-09 11:51:40 -04:00
|
|
|
|
|
|
|
describe '#execute' do
|
2016-08-30 18:11:46 -04:00
|
|
|
context 'when user is not authorized to reopen issue' do
|
2016-08-09 11:51:40 -04:00
|
|
|
before do
|
2016-08-12 15:05:10 -04:00
|
|
|
guest = create(:user)
|
|
|
|
project.team << [guest, :guest]
|
|
|
|
|
2016-08-09 11:51:40 -04:00
|
|
|
perform_enqueued_jobs do
|
2016-08-29 15:08:40 -04:00
|
|
|
described_class.new(project, guest).execute(issue)
|
2016-08-09 11:51:40 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not reopen the issue' do
|
2016-08-29 15:08:40 -04:00
|
|
|
expect(issue).to be_closed
|
2016-08-09 11:51:40 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-12 15:05:10 -04:00
|
|
|
|
2016-08-30 18:11:46 -04:00
|
|
|
context 'when user is authrized to reopen issue' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2016-08-12 15:05:10 -04:00
|
|
|
project.team << [user, :master]
|
2016-08-30 18:11:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when issue is not confidential' do
|
|
|
|
it 'executes issue hooks' do
|
|
|
|
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
|
|
|
|
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
|
2016-08-12 15:05:10 -04:00
|
|
|
|
2016-08-30 18:11:46 -04:00
|
|
|
described_class.new(project, user).execute(issue)
|
|
|
|
end
|
|
|
|
end
|
2016-08-12 15:05:10 -04:00
|
|
|
|
2016-08-30 18:11:46 -04:00
|
|
|
context 'when issue is confidential' do
|
|
|
|
it 'executes confidential issue hooks' do
|
|
|
|
issue = create(:issue, :confidential, :closed, project: project)
|
2016-08-12 15:05:10 -04:00
|
|
|
|
2016-08-30 18:11:46 -04:00
|
|
|
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
|
|
|
|
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
|
|
|
|
|
|
|
|
described_class.new(project, user).execute(issue)
|
|
|
|
end
|
2016-08-12 15:05:10 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-09 11:51:40 -04:00
|
|
|
end
|
|
|
|
end
|