diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-23 11:43:55 +0300 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-24 11:02:32 +0300 |
commit | 3be9820da63d77ab8b4469dbbb5385292f928057 (patch) | |
tree | aa8317a5e7736183f731ebd85be462efd23a1f82 /spec | |
parent | f0cd6ffd0bec0c8a612a7af6e8a9a0a6fa5d31a4 (diff) |
Test etag caching router and incorporate review
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/environments_controller_spec.rb | 13 | ||||
-rw-r--r-- | spec/lib/gitlab/etag_caching/router_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/deployment_spec.rb | 8 |
3 files changed, 19 insertions, 5 deletions
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index c0f8c36a018..62938a56bb4 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' describe Projects::EnvironmentsController do - let(:user) { create(:user) } - let(:project) { create(:empty_project) } + set(:user) { create(:user) } + set(:project) { create(:empty_project) } - let(:environment) do + set(:environment) do create(:environment, name: 'production', project: project) end before do - project.team << [user, :master] + project.add_master(user) sign_in(user) end @@ -57,6 +57,11 @@ describe Projects::EnvironmentsController do expect(json_response['available_count']).to eq 3 expect(json_response['stopped_count']).to eq 1 end + + it 'sets the polling interval header' do + expect(response).to have_http_status(:ok) + expect(response.headers['Poll-Interval']).to eq("3000") + end end context 'when requesting stopped environments scope' do diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb index 456bd9898ea..582ea85a1d6 100644 --- a/spec/lib/gitlab/etag_caching/router_spec.rb +++ b/spec/lib/gitlab/etag_caching/router_spec.rb @@ -84,7 +84,8 @@ describe Gitlab::EtagCaching::Router do result = described_class.match(env) - expect(result).to be_blank + expect(result).to be_present + expect(result.name).to eq 'environments' end def build_env(path) diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 4bda7d4314a..9e8acb3812b 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -16,6 +16,14 @@ 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 + it 'invalidates the cache for the environment' do + expect(subject).to receive(:invalidate_cache) + + subject.save! + end + end + describe '#includes_commit?' do let(:project) { create(:project, :repository) } let(:environment) { create(:environment, project: project) } |