Commit c735208e authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Fix NoMethodError for CommitController

* Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/351520
* Sentry error:
https://sentry.gitlab.net/gitlab/gitlabcom/issues/3214315

Changelog: fixed
parent 5a0af135
......@@ -106,6 +106,8 @@ class Projects::CommitController < Projects::ApplicationController
end
def revert
return render_404 unless @commit
assign_change_commit_vars
return render_404 if @start_branch.blank?
......@@ -117,6 +119,8 @@ class Projects::CommitController < Projects::ApplicationController
end
def cherry_pick
return render_404 unless @commit
assign_change_commit_vars
return render_404 if @start_branch.blank?
......
......@@ -212,6 +212,21 @@ RSpec.describe Projects::CommitController do
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
it 'redirects to the commits page' do
post(:revert,
......@@ -269,6 +284,21 @@ RSpec.describe Projects::CommitController do
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
it 'redirects to the commits page' do
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