Commit 500cef40 authored by Felipe Artur's avatar Felipe Artur

Fix error when archiving requirements

Make sure to call proper services when syncing work items
with requirements.
Prevents an error when archiving requirements.

Changelog: fixed
EE: true
parent 584868af
......@@ -38,6 +38,9 @@ module RequirementsManagement
def perform_sync(requirement, attributes)
requirement_issue = requirement.requirement_issue
state_change = attributes.delete(:state)
update_requirement_issue_state(requirement_issue, state_change)
::Issues::UpdateService.new(project: project, current_user: current_user, params: attributes)
.execute(requirement_issue)
end
......
......@@ -117,23 +117,32 @@ RSpec.describe RequirementsManagement::UpdateRequirementService do
context 'when updating state' do
context 'to archived' do
let(:params) do
{ state: 'archived' }
end
let(:params) { { state: 'archived' } }
it_behaves_like 'keeps requirement and its requirement_issue in sync'
it 'closes issue' do
expect_next_instance_of(::Issues::CloseService) do |service|
expect(service).to receive(:execute).with(requirement_issue, any_args).and_call_original
end
expect { subject }.to change { requirement.requirement_issue.reload.state }.from('opened').to('closed')
end
end
context 'to opened' do
let(:params) do
{ state: 'opened' }
end
let(:params) { { state: 'opened' } }
before do
requirement_issue.close
requirement.update!(state: 'archived')
end
it_behaves_like 'keeps requirement and its requirement_issue in sync'
it 'reopens issue' do
expect_next_instance_of(::Issues::ReopenService) do |service|
expect(service).to receive(:execute).with(requirement_issue, any_args).and_call_original
end
expect { subject }.to change { requirement.requirement_issue.reload.state }.from('closed').to('opened')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment