summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2015-05-10 07:21:39 +0000
committerMarin Jankovski <marin@gitlab.com>2015-05-10 07:21:39 +0000
commit6fdc51f81d013a1e01c0742e81cdd0fa5476e2d6 (patch)
tree4af10fd6527ee3de8a115541fef9f69f5e713efd
parent40c8295a24aace3210a8bc485f853d556a8bdc5c (diff)
parenta0fd2eb568cdbe3537f10a83191fde893a5d6fcd (diff)
downloadgitlab-ce-6fdc51f81d013a1e01c0742e81cdd0fa5476e2d6.tar.gz
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
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/user.rb2
-rw-r--r--features/project/deploy_keys.feature7
-rw-r--r--features/steps/project/deploy_keys.rb14
4 files changed, 18 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3206c625cd0..57567728b49 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
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)
diff --git a/app/models/user.rb b/app/models/user.rb
index 1cf7cfea974..a70cbaa518b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/features/project/deploy_keys.feature b/features/project/deploy_keys.feature
index a71f6124d9c..47cf774094f 100644
--- a/features/project/deploy_keys.feature
+++ b/features/project/deploy_keys.feature
@@ -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
+ 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
diff --git a/features/steps/project/deploy_keys.rb b/features/steps/project/deploy_keys.rb
index 50e14513a7a..81d1182cd1b 100644
--- a/features/steps/project/deploy_keys.rb
+++ b/features/steps/project/deploy_keys.rb
@@ -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