Test etag cache key changing value
This commit is contained in:
parent
7ec8969285
commit
f4aa01053e
|
@ -202,11 +202,16 @@ class Environment < ActiveRecord::Base
|
||||||
|
|
||||||
def expire_etag_cache
|
def expire_etag_cache
|
||||||
Gitlab::EtagCaching::Store.new.tap do |store|
|
Gitlab::EtagCaching::Store.new.tap do |store|
|
||||||
store.touch(Gitlab::Routing.url_helpers
|
store.touch(etag_cache_key)
|
||||||
.namespace_project_environments_path(project.namespace, project))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def etag_cache_key
|
||||||
|
Gitlab::Routing.url_helpers.namespace_project_environments_path(
|
||||||
|
project.namespace,
|
||||||
|
project)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Slugifying a name may remove the uniqueness guarantee afforded by it being
|
# Slugifying a name may remove the uniqueness guarantee afforded by it being
|
||||||
|
|
|
@ -42,6 +42,18 @@ describe Environment, models: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#expire_etag_cache' do
|
||||||
|
let(:store) { Gitlab::EtagCaching::Store.new }
|
||||||
|
|
||||||
|
it 'changes the cached value' do
|
||||||
|
old_value = store.get(environment.etag_cache_key)
|
||||||
|
|
||||||
|
environment.stop
|
||||||
|
|
||||||
|
expect(store.get(environment.etag_cache_key)).not_to eq(old_value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#nullify_external_url' do
|
describe '#nullify_external_url' do
|
||||||
it 'replaces a blank url with nil' do
|
it 'replaces a blank url with nil' do
|
||||||
env = build(:environment, external_url: "")
|
env = build(:environment, external_url: "")
|
||||||
|
|
Loading…
Reference in New Issue