Commit e0d2f249 authored by Adam Niedzielski's avatar Adam Niedzielski

Return 404 if deploy key cannot be found in Projects::DeployKeysController#disable

Closes #29633
parent d576fd82
......@@ -31,8 +31,10 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def disable
@project.deploy_keys_projects.find_by(deploy_key_id: params[:id]).destroy
deploy_key_project = @project.deploy_keys_projects.find_by(deploy_key_id: params[:id])
return render_404 unless deploy_key_project
deploy_key_project.destroy!
redirect_to_repository_settings(@project)
end
......
require 'spec_helper'
describe 'Project deploy keys', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project_empty_repo) }
before do
project.team << [user, :master]
login_as(user)
end
describe 'removing key' do
before do
create(:deploy_keys_project, project: project)
end
it 'removes association between project and deploy key' do
visit namespace_project_settings_repository_path(project.namespace, project)
page.within '.deploy-keys' do
expect { click_on 'Remove' }
.to change { project.deploy_keys.count }.by(-1)
end
end
end
end
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