Commit 7025b3f3 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'verify_commit_presence' into 'master'

Fix NoMethodError for CommitController

See merge request gitlab-org/gitlab!83123
parents f4e8f264 c735208e
...@@ -106,6 +106,8 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -106,6 +106,8 @@ class Projects::CommitController < Projects::ApplicationController
end end
def revert def revert
return render_404 unless @commit
assign_change_commit_vars assign_change_commit_vars
return render_404 if @start_branch.blank? return render_404 if @start_branch.blank?
...@@ -117,6 +119,8 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -117,6 +119,8 @@ class Projects::CommitController < Projects::ApplicationController
end end
def cherry_pick def cherry_pick
return render_404 unless @commit
assign_change_commit_vars assign_change_commit_vars
return render_404 if @start_branch.blank? return render_404 if @start_branch.blank?
......
...@@ -212,6 +212,21 @@ RSpec.describe Projects::CommitController do ...@@ -212,6 +212,21 @@ RSpec.describe Projects::CommitController do
end end
end end
context 'when the revert commit is missing' do
it 'renders the 404 page' do
post(:revert,
params: {
namespace_id: project.namespace,
project_id: project,
start_branch: 'master',
id: '1234567890'
})
expect(response).not_to be_successful
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when the revert was successful' do context 'when the revert was successful' do
it 'redirects to the commits page' do it 'redirects to the commits page' do
post(:revert, post(:revert,
...@@ -269,6 +284,21 @@ RSpec.describe Projects::CommitController do ...@@ -269,6 +284,21 @@ RSpec.describe Projects::CommitController do
end end
end end
context 'when the cherry-pick commit is missing' do
it 'renders the 404 page' do
post(:cherry_pick,
params: {
namespace_id: project.namespace,
project_id: project,
start_branch: 'master',
id: '1234567890'
})
expect(response).not_to be_successful
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when the cherry-pick was successful' do context 'when the cherry-pick was successful' do
it 'redirects to the commits page' do it 'redirects to the commits page' do
post(:cherry_pick, post(:cherry_pick,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment