2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe MergeRequests::ResolveTodosService, feature_category: :code_review_workflow do
|
2021-04-29 21:17:54 +05:30
|
|
|
let_it_be(:merge_request) { create(:merge_request) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
|
|
|
let(:service) { described_class.new(merge_request, user) }
|
|
|
|
|
|
|
|
describe '#async_execute' do
|
|
|
|
def async_execute
|
|
|
|
service.async_execute
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'performs MergeRequests::ResolveTodosWorker asynchronously' do
|
|
|
|
expect(MergeRequests::ResolveTodosWorker)
|
|
|
|
.to receive(:perform_async)
|
|
|
|
.with(
|
|
|
|
merge_request.id,
|
|
|
|
user.id
|
|
|
|
)
|
|
|
|
|
|
|
|
async_execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
it 'marks pending todo as done' do
|
|
|
|
pending_todo = create(:todo, :pending, user: user, project: merge_request.project, target: merge_request)
|
|
|
|
|
|
|
|
service.execute
|
|
|
|
|
|
|
|
expect(pending_todo.reload).to be_done
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|