diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-21 06:07:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-21 06:07:37 +0300 |
commit | bc3e57199e52e45799cb4d47ee2630af40d1edc3 (patch) | |
tree | ecf9aab2b81f91f857d4d116fbf4448675c7a2d8 /spec/models/deployment_spec.rb | |
parent | bb348db4c22bf58ac685fcd66445ac172491b302 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r-- | spec/models/deployment_spec.rb | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 33e4cd34aa5..15745441698 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -403,40 +403,37 @@ describe Deployment do describe '#previous_environment_deployment' do it 'returns the previous deployment of the same environment' do - deploy1 = create(:deployment, :success, ref: 'v1.0.0') + deploy1 = create(:deployment, :success) deploy2 = create( :deployment, :success, project: deploy1.project, - environment: deploy1.environment, - ref: 'v1.0.1' + environment: deploy1.environment ) expect(deploy2.previous_environment_deployment).to eq(deploy1) end it 'ignores deployments that were not successful' do - deploy1 = create(:deployment, :failed, ref: 'v1.0.0') + deploy1 = create(:deployment, :failed) deploy2 = create( :deployment, :success, project: deploy1.project, - environment: deploy1.environment, - ref: 'v1.0.1' + environment: deploy1.environment ) expect(deploy2.previous_environment_deployment).to be_nil end it 'ignores deployments for different environments' do - deploy1 = create(:deployment, :success, ref: 'v1.0.0') + deploy1 = create(:deployment, :success) preprod = create(:environment, project: deploy1.project, name: 'preprod') deploy2 = create( :deployment, :success, project: deploy1.project, - environment: preprod, - ref: 'v1.0.1' + environment: preprod ) expect(deploy2.previous_environment_deployment).to be_nil @@ -499,4 +496,36 @@ describe Deployment do end end end + + describe '#valid_sha' do + it 'does not add errors for a valid SHA' do + project = create(:project, :repository) + deploy = build(:deployment, project: project) + + expect(deploy).to be_valid + end + + it 'adds an error for an invalid SHA' do + deploy = build(:deployment, sha: 'foo') + + expect(deploy).not_to be_valid + expect(deploy.errors[:sha]).not_to be_empty + end + end + + describe '#valid_ref' do + it 'does not add errors for a valid ref' do + project = create(:project, :repository) + deploy = build(:deployment, project: project) + + expect(deploy).to be_valid + end + + it 'adds an error for an invalid ref' do + deploy = build(:deployment, ref: 'does-not-exist') + + expect(deploy).not_to be_valid + expect(deploy.errors[:ref]).not_to be_empty + end + end end |