diff options
-rw-r--r-- | app/assets/javascripts/breakpoints.js | 2 | ||||
-rw-r--r-- | app/services/update_deployment_service.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/11124-update-deployment-service-fails-if-project-is-nil.yml | 5 | ||||
-rw-r--r-- | spec/javascripts/breakpoints_spec.js | 14 | ||||
-rw-r--r-- | spec/services/update_deployment_service_spec.rb | 37 |
5 files changed, 48 insertions, 12 deletions
diff --git a/app/assets/javascripts/breakpoints.js b/app/assets/javascripts/breakpoints.js index 4d5d6bb864b..93aacba0e8e 100644 --- a/app/assets/javascripts/breakpoints.js +++ b/app/assets/javascripts/breakpoints.js @@ -15,7 +15,7 @@ const BreakpointInstance = { return breakpoint; }, isDesktop() { - return ['lg', 'md'].includes(this.getBreakpointSize); + return ['lg', 'md'].includes(this.getBreakpointSize()); }, }; diff --git a/app/services/update_deployment_service.rb b/app/services/update_deployment_service.rb index aa7fcca1e2a..49a7d0178f4 100644 --- a/app/services/update_deployment_service.rb +++ b/app/services/update_deployment_service.rb @@ -27,6 +27,8 @@ class UpdateDeploymentService deployment.tap(&:update_merge_request_metrics!) end + + deployment end private diff --git a/changelogs/unreleased/11124-update-deployment-service-fails-if-project-is-nil.yml b/changelogs/unreleased/11124-update-deployment-service-fails-if-project-is-nil.yml new file mode 100644 index 00000000000..355743f4cb0 --- /dev/null +++ b/changelogs/unreleased/11124-update-deployment-service-fails-if-project-is-nil.yml @@ -0,0 +1,5 @@ +--- +title: Always return the deployment in the UpdateDeploymentService#execute method +merge_request: 27322 +author: +type: fixed diff --git a/spec/javascripts/breakpoints_spec.js b/spec/javascripts/breakpoints_spec.js index 5ee777fee3f..fc0d9eb907a 100644 --- a/spec/javascripts/breakpoints_spec.js +++ b/spec/javascripts/breakpoints_spec.js @@ -10,4 +10,18 @@ describe('breakpoints', () => { expect(bp.getBreakpointSize()).toBe(key); }); }); + + describe('isDesktop', () => { + it('returns true when screen size is medium', () => { + spyOn(bp, 'windowWidth').and.returnValue(breakpoints.md + 10); + + expect(bp.isDesktop()).toBe(true); + }); + + it('returns false when screen size is small', () => { + spyOn(bp, 'windowWidth').and.returnValue(breakpoints.sm + 10); + + expect(bp.isDesktop()).toBe(false); + }); + }); }); diff --git a/spec/services/update_deployment_service_spec.rb b/spec/services/update_deployment_service_spec.rb index e1643233321..c664bac39fc 100644 --- a/spec/services/update_deployment_service_spec.rb +++ b/spec/services/update_deployment_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe UpdateDeploymentService do let(:user) { create(:user) } + let(:project) { create(:project, :repository) } let(:options) { { name: 'production' } } let(:job) do @@ -15,24 +16,22 @@ describe UpdateDeploymentService do project: project) end - let(:project) { create(:project, :repository) } - let(:environment) { deployment.environment } let(:deployment) { job.deployment } - let(:service) { described_class.new(deployment) } + let(:environment) { deployment.environment } + + subject(:service) { described_class.new(deployment) } before do job.success! # Create/Succeed deployment end describe '#execute' do - subject { service.execute } - let(:store) { Gitlab::EtagCaching::Store.new } it 'invalidates the environment etag cache' do old_value = store.get(environment.etag_cache_key) - subject + service.execute expect(store.get(environment.etag_cache_key)).not_to eq(old_value) end @@ -42,14 +41,30 @@ describe UpdateDeploymentService do .to receive(:create_ref) .with(deployment.ref, deployment.send(:ref_path)) - subject + service.execute end it 'updates merge request metrics' do expect_any_instance_of(Deployment) .to receive(:update_merge_request_metrics!) - subject + service.execute + end + + it 'returns the deployment' do + expect(subject.execute).to eq(deployment) + end + + it 'returns the deployment when could not save the environment' do + allow(environment).to receive(:save).and_return(false) + + expect(subject.execute).to eq(deployment) + end + + it 'returns the deployment when environment is stopped' do + allow(environment).to receive(:stopped?).and_return(true) + + expect(subject.execute).to eq(deployment) end context 'when start action is defined' do @@ -61,7 +76,7 @@ describe UpdateDeploymentService do end it 'makes environment available' do - subject + service.execute expect(environment.reload).to be_available end @@ -80,11 +95,11 @@ describe UpdateDeploymentService do end it 'does not create a new environment' do - expect { subject }.not_to change { Environment.count } + expect { subject.execute }.not_to change { Environment.count } end it 'updates external url' do - subject + subject.execute expect(subject.environment.name).to eq('review-apps/master') expect(subject.environment.external_url).to eq('http://master.review-apps.gitlab.com') |