Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAriejan de Vroom <ariejan@ariejan.net>2012-03-01 19:00:14 +0400
committerAriejan de Vroom <ariejan@ariejan.net>2012-03-01 19:00:14 +0400
commitb0ce61c4f20abe1ca5c99631517b49c99f8b23ef (patch)
treef43439eba70d0815da2528d8110c456440a3ff12 /spec/models/key_spec.rb
parentbfe0906f2ff7a79064c1866c0278cd0c9440b246 (diff)
parentf5a16663f0b038aeb397bda19ebdefa6ad873955 (diff)
Merge branch 'deploy_keys_nonunique' of https://github.com/miks/gitlabhq into miks-deploy_keys_nonunique
Added/fixed specs Update spec/factory to allow Factory#new without opts Conflicts: app/models/key.rb
Diffstat (limited to 'spec/models/key_spec.rb')
-rw-r--r--spec/models/key_spec.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 44963e3cea7..b24f22cad96 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -14,8 +14,40 @@ describe Key do
it { should respond_to :projects }
end
- it { Factory.create(:key,
- :user => Factory(:user)).should be_valid }
+ context "validation of uniqueness" do
+
+ context "as a deploy key" do
+ let(:project) { Factory.create(:project, path: 'alpha', code: 'alpha') }
+ let(:another_project) { Factory.create(:project, path: 'beta', code: 'beta') }
+
+ before do
+ deploy_key = Factory.create(:key, project: project)
+ end
+
+ it "does not accept the same key twice for a project" do
+ key = Factory.new(:key, project: project)
+ key.should_not be_valid
+ end
+
+ it "does accept the same key for another project" do
+ key = Factory.new(:key, project: another_project)
+ key.should be_valid
+ end
+ end
+
+ context "as a personal key" do
+ let(:user) { Factory.create(:user) }
+
+ it "accepts the key once" do
+ Factory.new(:key, user: user).should be_valid
+ end
+
+ it "does not accepts the key twice" do
+ Factory.create(:key, user: user)
+ Factory.new(:key, user: user).should_not be_valid
+ end
+ end
+ end
end
# == Schema Information
#