diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-30 23:56:26 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-31 19:24:43 +0200 |
commit | f4aa01053ed39a265ddfd9ee6e9618bd3406e59d (patch) | |
tree | 2b276d3a0bb51f89b79b1f281a95b32dfd91eda1 | |
parent | 7ec89692858a207691489aed566af7785a923895 (diff) | |
download | gitlab-ce-f4aa01053ed39a265ddfd9ee6e9618bd3406e59d.tar.gz |
Test etag cache key changing value
-rw-r--r-- | app/models/environment.rb | 9 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 07722d9a59e..6211a5c1e63 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -202,11 +202,16 @@ class Environment < ActiveRecord::Base def expire_etag_cache Gitlab::EtagCaching::Store.new.tap do |store| - store.touch(Gitlab::Routing.url_helpers - .namespace_project_environments_path(project.namespace, project)) + store.touch(etag_cache_key) end end + def etag_cache_key + Gitlab::Routing.url_helpers.namespace_project_environments_path( + project.namespace, + project) + end + private # Slugifying a name may remove the uniqueness guarantee afforded by it being diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 768f557bb9f..b6162908e12 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -42,6 +42,18 @@ describe Environment, models: true do 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 it 'replaces a blank url with nil' do env = build(:environment, external_url: "") |