Commit fdc855e3 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'issue_343778' into 'master'

Fix error when archiving requirements

See merge request gitlab-org/gitlab!73010
parents 736b1b6f 500cef40
......@@ -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