diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index 1d0b4183f969081c419aba71ee4911d6a73057b6..568d0f6aa8f20b3df7adea0813ba07e218dcfc80 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -99,7 +99,7 @@ class DiffsEntity < Grape::Entity
   end
 
   def commit_options(options)
-    prev_commit_id, next_commit_id = *commit_neighbors(options[:commit]&.id)
+    next_commit_id, prev_commit_id = *commit_neighbors(options[:commit]&.id)
 
     options.merge(
       type: :full,
diff --git a/spec/serializers/diffs_entity_spec.rb b/spec/serializers/diffs_entity_spec.rb
index b42240037df76148ad5c599717c8bbe0e4591149..482f9e76c625c70cb63b72c698f07d10564d31c0 100644
--- a/spec/serializers/diffs_entity_spec.rb
+++ b/spec/serializers/diffs_entity_spec.rb
@@ -45,26 +45,26 @@ describe DiffsEntity 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)
+          expect(subject[:commit][:next_commit_id]).to eq(commits.second.id)
+          expect(subject[:commit][:prev_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)
+        it 'includes commit references for nil and previous commit' do
+          expect(subject[:commit][:next_commit_id]).to be_nil
+          expect(subject[:commit][:prev_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
+        it 'includes commit references for the next and nil' do
+          expect(subject[:commit][:next_commit_id]).to eq(commits[-2].id)
+          expect(subject[:commit][:prev_commit_id]).to be_nil
         end
       end
     end