diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-01-03 15:06:20 +0100 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2018-01-03 18:34:31 +0100 |
commit | 10637f0ba9f908c02d6c8e3b2cadf694e9d1170a (patch) | |
tree | ca4cc5c511f2bc7adc2a4d5d3a4050b2e595f1fe /spec/models/deployment_spec.rb | |
parent | 91cb64bf0fb3096f07174585f5a0e3db69181571 (diff) | |
download | gitlab-ce-pawel/last-deployment-check.tar.gz |
Add first? deployment check to see if a deployment is a first one for given environmentpawel/last-deployment-check
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r-- | spec/models/deployment_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index ba8aa13d5ad..a9226340d96 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -29,6 +29,38 @@ describe Deployment do end end + describe '#last?' do + let(:environment) { create(:environment) } + let!(:first_deployment) { create(:deployment, environment: environment) } + let!(:middle_deployment) { create(:deployment, environment: environment) } + let!(:last_deployment) { create(:deployment, environment: environment) } + + it 'is true for last deployment ' do + expect(last_deployment.last?).to be(true) + end + + it 'is false for previous deployments' do + expect(middle_deployment.last?).to be(false) + expect(first_deployment.last?).to be(false) + end + end + + describe '#first?' do + let(:environment) { create(:environment) } + let!(:first_deployment) { create(:deployment, environment: environment) } + let!(:second_deployment) { create(:deployment, environment: environment) } + let!(:last_deployment) { create(:deployment, environment: environment) } + + it 'is true for first deployment' do + expect(first_deployment.first?).to be(true) + end + + it 'is false for subsequent deployments' do + expect(second_deployment.first?).to be(false) + expect(last_deployment.first?).to be(false) + end + end + describe '#includes_commit?' do let(:project) { create(:project, :repository) } let(:environment) { create(:environment, project: project) } |