diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-12 15:19:27 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-22 21:55:43 +0200 |
commit | ebede2b3ff1c2b089529c4f9d6268641580e280b (patch) | |
tree | 08d0463762501180bf45444cd88cacf085e9bcd4 /spec | |
parent | 50a00442285973a390fa448d189ee43cd700d668 (diff) | |
download | gitlab-ce-ebede2b3ff1c2b089529c4f9d6268641580e280b.tar.gz |
Use etag caching for environments JSON
For the index view, the environments can now be requested every 15
seconds. Any transition state of a projects environments will trigger a
cache invalidation action.
Fixes gitlab-org/gitlab-ce#31701
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/etag_caching/router_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 10 |
2 files changed, 19 insertions, 1 deletions
diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb index 5ae4a19263c..456bd9898ea 100644 --- a/spec/lib/gitlab/etag_caching/router_spec.rb +++ b/spec/lib/gitlab/etag_caching/router_spec.rb @@ -77,6 +77,16 @@ describe Gitlab::EtagCaching::Router do expect(result).to be_blank end + it 'matches the environments path' do + env = build_env( + '/my-group/my-project/environments.json' + ) + + result = described_class.match(env) + + expect(result).to be_blank + end + def build_env(path) { 'PATH_INFO' => path } end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 12519de8636..768f557bb9f 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Environment, models: true do - let(:project) { create(:empty_project) } + set(:project) { create(:empty_project) } subject(:environment) { create(:environment, project: project) } it { is_expected.to belong_to(:project) } @@ -34,6 +34,14 @@ describe Environment, models: true do end end + describe 'state machine' do + it 'invalidates the cache after a change' do + expect(environment).to receive(:expire_etag_cache) + + environment.stop + end + end + describe '#nullify_external_url' do it 'replaces a blank url with nil' do env = build(:environment, external_url: "") |