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.
This commit is contained in:
Z.J. van de Weg 2017-06-01 16:59:18 +02:00
parent 00b00f1ede
commit 696b039511

View file

@ -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