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:
Diffstat (limited to 'spec/lib/gitlab/pages/cache_control_spec.rb')
-rw-r--r--spec/lib/gitlab/pages/cache_control_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/pages/cache_control_spec.rb b/spec/lib/gitlab/pages/cache_control_spec.rb
new file mode 100644
index 00000000000..6ed823427fb
--- /dev/null
+++ b/spec/lib/gitlab/pages/cache_control_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Pages::CacheControl do
+ it 'fails with invalid type' do
+ expect { described_class.new(type: :unknown, id: nil) }
+ .to raise_error(ArgumentError, "type must be :namespace or :project")
+ end
+
+ describe '.for_namespace' do
+ let(:subject) { described_class.for_namespace(1) }
+
+ it { expect(subject.cache_key).to eq('pages_domain_for_namespace_1') }
+
+ describe '#clear_cache' do
+ it 'clears the cache' do
+ expect(Rails.cache)
+ .to receive(:delete)
+ .with('pages_domain_for_namespace_1')
+
+ subject.clear_cache
+ end
+ end
+ end
+
+ describe '.for_project' do
+ let(:subject) { described_class.for_project(1) }
+
+ it { expect(subject.cache_key).to eq('pages_domain_for_project_1') }
+
+ describe '#clear_cache' do
+ it 'clears the cache' do
+ expect(Rails.cache)
+ .to receive(:delete)
+ .with('pages_domain_for_project_1')
+
+ subject.clear_cache
+ end
+ end
+ end
+end