Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-09 18:11:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-09 18:11:31 +0300
commit283318c20561cc040b62397060771efa74db0d90 (patch)
tree31b724e53806352b1bff5e1e460e6f4445c4e0a0 /spec/workers
parent1f229cdc22b5b32989bcff2037d8925c75703671 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/pages/invalidate_domain_cache_worker_spec.rb66
1 files changed, 58 insertions, 8 deletions
diff --git a/spec/workers/pages/invalidate_domain_cache_worker_spec.rb b/spec/workers/pages/invalidate_domain_cache_worker_spec.rb
index 15a2c389482..49dcd18d64e 100644
--- a/spec/workers/pages/invalidate_domain_cache_worker_spec.rb
+++ b/spec/workers/pages/invalidate_domain_cache_worker_spec.rb
@@ -13,8 +13,8 @@ RSpec.describe Pages::InvalidateDomainCacheWorker do
it_behaves_like 'subscribes to event'
it 'clears the cache with Gitlab::Pages::CacheControl' do
- caches.each do |cache_type, cache_id|
- expect_next_instance_of(Gitlab::Pages::CacheControl, type: cache_type, id: cache_id) do |cache_control|
+ caches.each do |cache|
+ expect_next_instance_of(Gitlab::Pages::CacheControl, type: cache[:type], id: cache[:id]) do |cache_control|
expect(cache_control).to receive(:clear_cache)
end
end
@@ -26,27 +26,42 @@ RSpec.describe Pages::InvalidateDomainCacheWorker do
it_behaves_like 'clears caches with',
event_class: Pages::PageDeployedEvent,
event_data: { project_id: 1, namespace_id: 2, root_namespace_id: 3 },
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
it_behaves_like 'clears caches with',
event_class: Pages::PageDeletedEvent,
event_data: { project_id: 1, namespace_id: 2, root_namespace_id: 3 },
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
it_behaves_like 'clears caches with',
event_class: Projects::ProjectDeletedEvent,
event_data: { project_id: 1, namespace_id: 2, root_namespace_id: 3 },
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
it_behaves_like 'clears caches with',
event_class: Projects::ProjectCreatedEvent,
event_data: { project_id: 1, namespace_id: 2, root_namespace_id: 3 },
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
it_behaves_like 'clears caches with',
event_class: Projects::ProjectArchivedEvent,
event_data: { project_id: 1, namespace_id: 2, root_namespace_id: 3 },
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
it_behaves_like 'clears caches with',
event_class: Projects::ProjectPathChangedEvent,
@@ -57,5 +72,40 @@ RSpec.describe Pages::InvalidateDomainCacheWorker do
old_path: 'old_path',
new_path: 'new_path'
},
- caches: { namespace: 3, project: 1 }
+ caches: [
+ { type: :namespace, id: 3 },
+ { type: :project, id: 1 }
+ ]
+
+ it_behaves_like 'clears caches with',
+ event_class: Projects::ProjectTransferedEvent,
+ event_data: {
+ project_id: 1,
+ old_namespace_id: 2,
+ old_root_namespace_id: 3,
+ new_namespace_id: 4,
+ new_root_namespace_id: 5
+ },
+ caches: [
+ { type: :project, id: 1 },
+ { type: :namespace, id: 3 },
+ { type: :namespace, id: 5 }
+ ]
+
+ context 'when namespace based cache keys are duplicated' do
+ # de-dups namespace cache keys
+ it_behaves_like 'clears caches with',
+ event_class: Projects::ProjectTransferedEvent,
+ event_data: {
+ project_id: 1,
+ old_namespace_id: 2,
+ old_root_namespace_id: 5,
+ new_namespace_id: 4,
+ new_root_namespace_id: 5
+ },
+ caches: [
+ { type: :project, id: 1 },
+ { type: :namespace, id: 5 }
+ ]
+ end
end