summaryrefslogtreecommitdiff
path: root/spec/models/key_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-08-28 07:01:27 -0400
committerRobert Speicher <rspeicher@gmail.com>2012-08-28 21:22:49 -0400
commit77d06454ededc3beef09db709829ccb687ccc045 (patch)
treed051a03c8753fb8947fe94638120ede631b8041c /spec/models/key_spec.rb
parent0bc909405852135d7f98440193830eba664ea122 (diff)
downloadgitlab-ce-77d06454ededc3beef09db709829ccb687ccc045.tar.gz
Simple model spec changes made possible by new factories
Diffstat (limited to 'spec/models/key_spec.rb')
-rw-r--r--spec/models/key_spec.rb17
1 files changed, 6 insertions, 11 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 0f9b31778df..ea58fbd291e 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -17,20 +17,15 @@ describe Key do
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
+ let!(:deploy_key) { create(:deploy_key) }
it "does not accept the same key twice for a project" do
- key = Factory.new(:key, project: project)
+ key = build(:key, project: deploy_key.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 = build(:key, project_id: 0)
key.should be_valid
end
end
@@ -39,12 +34,12 @@ describe Key do
let(:user) { Factory.create(:user) }
it "accepts the key once" do
- Factory.new(:key, user: user).should be_valid
+ build(: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
+ create(:key, user: user)
+ build(:key, user: user).should_not be_valid
end
end
end