Commit 6fdc51f8 authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'bug/fix-duplicate-deploy-keys' into 'master'

Don't show duplicate deploy keys

This fixes the issue described in [#1516](https://gitlab.com/gitlab-org/gitlab-ce/issues/1516) where you would see the same deploy key multiple times if it was used by multiple projects.

See merge request !629
parents 40c8295a a0fd2eb5
No related merge requests found
Please view this file on the master branch, on stable branches it's out of date.
v 7.11.0 (unreleased)
- Don't show duplicate deploy keys
- Make the first branch pushed to an empty repository the default HEAD (Stan Hu)
- Make Reply-To config apply to change e-mail confirmation and other Devise notifications (Stan Hu)
- Add application setting to restrict user signups to e-mail domains (Stan Hu)
......
......@@ -438,7 +438,7 @@ class User < ActiveRecord::Base
end
def project_deploy_keys
DeployKey.in_projects(self.authorized_projects.pluck(:id))
DeployKey.unscoped.in_projects(self.authorized_projects.pluck(:id)).distinct(:id)
end
def accessible_deploy_keys
......
......@@ -9,9 +9,10 @@ Feature: Project Deploy Keys
Then I should see project deploy key
Scenario: I should see project deploy keys
Given other project has deploy key
Given other projects have deploy keys
When I visit project deploy keys page
Then I should see other project deploy key
And I should only see the same deploy key once
Scenario: I should see public deploy keys
Given public deploy key exists
......@@ -26,7 +27,7 @@ Feature: Project Deploy Keys
And I should see newly created deploy key
Scenario: I attach other project deploy key to project
Given other project has deploy key
Given other projects have deploy keys
And I visit project deploy keys page
When I click attach deploy key
Then I should be on deploy keys page
......
......@@ -45,10 +45,20 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end
end
step 'other project has deploy key' do
@second_project = create :project, namespace: create(:group)
step 'other projects have deploy keys' do
@second_project = create(:project, namespace: create(:group))
@second_project.team << [current_user, :master]
create(:deploy_keys_project, project: @second_project)
@third_project = create(:project, namespace: create(:group))
@third_project.team << [current_user, :master]
create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first)
end
step 'I should only see the same deploy key once' do
within '.available-keys' do
page.should have_selector('ul li', count: 1)
end
end
step 'public deploy key exists' do
......
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