From 696b0395116f9f973c919b281a1a5df023f22084 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 1 Jun 2017 16:59:18 +0200 Subject: Explicitly test etag cache invalidation When a new deployment is created, this will trigger the invalidation on the etag cache on the environment. This flow is now explicitly tested. --- spec/models/deployment_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 9e8acb3812b..6f0d2db23c7 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -17,10 +17,15 @@ describe Deployment, models: true do it { is_expected.to validate_presence_of(:sha) } describe 'after_create callbacks' do - it 'invalidates the cache for the environment' do - expect(subject).to receive(:invalidate_cache) + let(:environment) { create(:environment) } + let(:store) { Gitlab::EtagCaching::Store.new } - subject.save! + it 'invalidates the environment etag cache' do + old_value = store.get(environment.etag_cache_key) + + create(:deployment, environment: environment) + + expect(store.get(environment.etag_cache_key)).not_to eq(old_value) end end -- cgit v1.2.1