diff options
Diffstat (limited to 'spec/services/issues/reopen_service_spec.rb')
-rw-r--r-- | spec/services/issues/reopen_service_spec.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index 86190c4e475..c9469b861ac 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -8,18 +8,26 @@ RSpec.describe Issues::ReopenService do describe '#execute' do context 'when user is not authorized to reopen issue' do - before do + it 'does not reopen the issue' do guest = create(:user) project.add_guest(guest) - perform_enqueued_jobs do - described_class.new(project: project, current_user: guest).execute(issue) - end - end + described_class.new(project: project, current_user: guest).execute(issue) - it 'does not reopen the issue' do expect(issue).to be_closed end + + context 'when skip_authorization is true' do + it 'does close the issue even if user is not authorized' do + non_authorized_user = create(:user) + + service = described_class.new(project: project, current_user: non_authorized_user) + + expect do + service.execute(issue, skip_authorization: true) + end.to change { issue.reload.state }.from('closed').to('opened') + end + end end context 'when user is authorized to reopen issue' do |