Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 15:08:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 15:08:18 +0300
commit684d65316ac77c62f47d68b9926eea8af30db227 (patch)
treed1f4c4eec399d7772ab4ad6294f98e7505c1cee5 /spec/serializers
parentade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/diffs_entity_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/serializers/diffs_entity_spec.rb b/spec/serializers/diffs_entity_spec.rb
index bb4ac5f9608..b42240037df 100644
--- a/spec/serializers/diffs_entity_spec.rb
+++ b/spec/serializers/diffs_entity_spec.rb
@@ -26,5 +26,47 @@ describe DiffsEntity do
:merge_request_diffs, :definition_path_prefix
)
end
+
+ context "when a commit_id is passed" do
+ let(:commits) { merge_request.commits }
+ let(:entity) do
+ described_class.new(
+ merge_request_diffs.first.diffs,
+ request: request,
+ merge_request: merge_request,
+ merge_request_diffs: merge_request_diffs,
+ commit: commit
+ )
+ end
+
+ subject { entity.as_json }
+
+ context "when the passed commit is not the first or last in the group" do
+ let(:commit) { commits.third }
+
+ it 'includes commit references for previous and next' do
+ expect(subject[:commit][:prev_commit_id]).to eq(commits.second.id)
+ expect(subject[:commit][:next_commit_id]).to eq(commits.fourth.id)
+ end
+ end
+
+ context "when the passed commit is the first in the group" do
+ let(:commit) { commits.first }
+
+ it 'includes commit references for nil and next' do
+ expect(subject[:commit][:prev_commit_id]).to be_nil
+ expect(subject[:commit][:next_commit_id]).to eq(commits.second.id)
+ end
+ end
+
+ context "when the passed commit is the last in the group" do
+ let(:commit) { commits.last }
+
+ it 'includes commit references for previous and nil' do
+ expect(subject[:commit][:prev_commit_id]).to eq(commits[-2].id)
+ expect(subject[:commit][:next_commit_id]).to be_nil
+ end
+ end
+ end
end
end