summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/data_builder/deployment_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/lib/gitlab/data_builder/deployment_spec.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/lib/gitlab/data_builder/deployment_spec.rb')
-rw-r--r--spec/lib/gitlab/data_builder/deployment_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/data_builder/deployment_spec.rb b/spec/lib/gitlab/data_builder/deployment_spec.rb
index ab8c8a51694..e8fe80f75cb 100644
--- a/spec/lib/gitlab/data_builder/deployment_spec.rb
+++ b/spec/lib/gitlab/data_builder/deployment_spec.rb
@@ -46,5 +46,42 @@ RSpec.describe Gitlab::DataBuilder::Deployment do
expect(data[:deployable_url]).to be_nil
end
+
+ context 'when commit does not exist in the repository' do
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:deployment) { create(:deployment, project: project) }
+
+ subject(:data) { described_class.build(deployment, Time.current) }
+
+ before(:all) do
+ project.repository.remove
+ end
+
+ it 'returns nil for commit_url' do
+ expect(data[:commit_url]).to be_nil
+ end
+
+ it 'returns nil for commit_title' do
+ expect(data[:commit_title]).to be_nil
+ end
+ end
+
+ context 'when deployed_by is nil' do
+ let_it_be(:deployment) { create(:deployment, user: nil, deployable: nil) }
+
+ subject(:data) { described_class.build(deployment, Time.current) }
+
+ before(:all) do
+ deployment.user = nil
+ end
+
+ it 'returns nil for user' do
+ expect(data[:user]).to be_nil
+ end
+
+ it 'returns nil for user_url' do
+ expect(data[:user_url]).to be_nil
+ end
+ end
end
end