summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-24 15:06:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-24 15:06:02 +0000
commit8db8e2a34205c67e358cf544745d9eaeb30cd032 (patch)
treeabfd747d94a4a77e0dfac5ac29cd7b57343edff9 /spec/serializers
parent33813f993b49da58426d33a148ee70952e6835bb (diff)
downloadgitlab-ce-8db8e2a34205c67e358cf544745d9eaeb30cd032.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/merge_request_diff_entity_spec.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/serializers/merge_request_diff_entity_spec.rb b/spec/serializers/merge_request_diff_entity_spec.rb
index 062f17963c0..59ec0b22158 100644
--- a/spec/serializers/merge_request_diff_entity_spec.rb
+++ b/spec/serializers/merge_request_diff_entity_spec.rb
@@ -7,14 +7,15 @@ describe MergeRequestDiffEntity do
let(:request) { EntityRequest.new(project: project) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_diffs) { merge_request.merge_request_diffs }
+ let(:merge_request_diff) { merge_request_diffs.first }
let(:entity) do
- described_class.new(merge_request_diffs.first, request: request, merge_request: merge_request, merge_request_diffs: merge_request_diffs)
+ described_class.new(merge_request_diff, request: request, merge_request: merge_request, merge_request_diffs: merge_request_diffs)
end
- context 'as json' do
- subject { entity.as_json }
+ subject { entity.as_json }
+ context 'as json' do
it 'exposes needed attributes' do
expect(subject).to include(
:version_index, :created_at, :commits_count,
@@ -23,4 +24,16 @@ describe MergeRequestDiffEntity do
)
end
end
+
+ describe '#short_commit_sha' do
+ it 'returns short sha' do
+ expect(subject[:short_commit_sha]).to eq('b83d6e39')
+ end
+
+ it 'returns nil if head_commit_sha does not exist' do
+ allow(merge_request_diff).to receive(:head_commit_sha).and_return(nil)
+
+ expect(subject[:short_commit_sha]).to eq(nil)
+ end
+ end
end