Commit cb41ff09 authored by James Fargher's avatar James Fargher

Merge branch 'create_close_issue_event_on_issue_move' into 'master'

Create close issue event on issue move

See merge request gitlab-org/gitlab!64197
parents 10f9f900 46d22192
......@@ -66,7 +66,7 @@ module Issuable
def close_issue
close_service = Issues::CloseService.new(project: old_project, current_user: current_user)
close_service.execute(original_entity, notifications: false, system_note: false)
close_service.execute(original_entity, notifications: false, system_note: true)
end
def new_parent
......
......@@ -48,6 +48,10 @@ RSpec.describe 'Setting the epic of an issue' do
before do
stub_licensed_features(epics: true)
# todo: investigate too many qeuries issue as part of Project Management Database and Query Performance
# epic: https://gitlab.com/groups/gitlab-org/-/epics/5804
# specific issue: https://gitlab.com/gitlab-org/gitlab/-/issues/333845
stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 110)
end
it 'returns an error if the user is not allowed to update the issue' do
......@@ -95,7 +99,7 @@ RSpec.describe 'Setting the epic of an issue' do
new_epic_group.add_developer(current_user)
end
it 'promotes the issue to epic', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/333845' do
it 'promotes the issue to epic' do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
......
......@@ -137,6 +137,15 @@ RSpec.describe Epics::IssuePromoteService, :aggregate_failures do
expect { subject.execute(issue) }.not_to raise_error
end
it 'creates a close state event for promoted issue' do
# promote issue to epic also copies over existing issue state resource events to the epic
# so in this case we have an existing resource event defined above and one that we create
# for issue close event, which we are not copying over
expect { subject.execute(issue) }.to change(ResourceStateEvent, :count).by(2).and(
change(ResourceStateEvent.where(issue_id: issue), :count).by(1)
)
end
it 'promotes issue successfully' do
epic = subject.execute(issue)
......
......@@ -38,6 +38,10 @@ RSpec.describe Issues::MoveService do
context 'issue movable' do
include_context 'user can move issue'
it 'creates resource state event' do
expect { move_service.execute(old_issue, new_project) }.to change(ResourceStateEvent.where(issue_id: old_issue), :count).by(1)
end
context 'generic issue' do
include_context 'issue move executed'
......@@ -87,6 +91,10 @@ RSpec.describe Issues::MoveService do
expect(old_issue.moved_to).to eq new_issue
end
it 'marks issue as closed' do
expect(old_issue.closed?).to eq true
end
it 'preserves create time' do
expect(old_issue.created_at).to eq new_issue.created_at
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