Skip to content
Snippets Groups Projects
Commit 0d910e89 authored by Kassio Borges's avatar Kassio Borges :three: Committed by Kassio Borges
Browse files

Send root_namespace_id to the Projects::ProjectDeletedEvent

To be able to invalidate the GitLab Pages internal API cache when a
Project is deleted, this event now also provides the deleted project's
`root_namespace_id`.

Related to: #364065

Changelog: changed
parent ca74d114
No related branches found
No related tags found
1 merge request!91422Send root_namespace_id to the Projects::ProjectDeletedEvent
This commit is part of merge request !91692. Comments created here will be created in the context of that merge request.
......@@ -7,7 +7,8 @@ def schema
'type' => 'object',
'properties' => {
'project_id' => { 'type' => 'integer' },
'namespace_id' => { 'type' => 'integer' }
'namespace_id' => { 'type' => 'integer' },
'root_namespace_id' => { 'type' => 'integer' }
},
'required' => %w[project_id namespace_id]
}
......
......@@ -263,8 +263,12 @@ def flush_caches(project)
end
def publish_project_deleted_event_for(project)
data = { project_id: project.id, namespace_id: project.namespace_id }
event = Projects::ProjectDeletedEvent.new(data: data)
event = Projects::ProjectDeletedEvent.new(data: {
project_id: project.id,
namespace_id: project.namespace_id,
root_namespace_id: project.root_namespace.id
})
Gitlab::EventStore.publish(event)
end
end
......
......@@ -6,6 +6,7 @@
where(:data, :valid) do
[
[{ project_id: 1, namespace_id: 2 }, true],
[{ project_id: 1, namespace_id: 2, root_namespace_id: 3 }, true],
[{ project_id: 1 }, false],
[{ namespace_id: 1 }, false],
[{ project_id: 'foo', namespace_id: 2 }, false],
......
......@@ -26,7 +26,11 @@
end
it 'publishes a ProjectDeleted event with project id and namespace id' do
expected_data = { project_id: project.id, namespace_id: project.namespace_id }
expected_data = {
project_id: project.id,
namespace_id: project.namespace_id,
root_namespace_id: project.root_namespace.id
}
expect { destroy_project(project, user, {}) }.to publish_event(Projects::ProjectDeletedEvent).with(expected_data)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment