diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-01 20:38:46 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-01 20:38:46 +0000 |
commit | 8d131eb85ddc1ee6cd4a27830b2607617d767f28 (patch) | |
tree | ec42e6d1ea049de36c21de8b3017988963bd5289 /spec/models | |
parent | b92e3d746466667642fd99d1ed72b481488d1a9f (diff) | |
parent | 696b0395116f9f973c919b281a1a5df023f22084 (diff) | |
download | gitlab-ce-8d131eb85ddc1ee6cd4a27830b2607617d767f28.tar.gz |
Merge branch 'zj-realtime-env-list' into 'master'
Realtime env list
Closes #31701
See merge request !11333
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/deployment_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 22 |
2 files changed, 34 insertions, 1 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 4bda7d4314a..6f0d2db23c7 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -16,6 +16,19 @@ describe Deployment, models: true do it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } + describe 'after_create callbacks' do + let(:environment) { create(:environment) } + let(:store) { Gitlab::EtagCaching::Store.new } + + 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 + describe '#includes_commit?' do let(:project) { create(:project, :repository) } let(:environment) { create(:environment, project: project) } diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 9fbe19b04d5..fe69c8e351d 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,26 @@ 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 '#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: "") |