From 3ada8f45c7a719a95864b3ee2c1acdfdf4468eaa Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 2 Jul 2013 13:39:13 +0200 Subject: Remove unnecessary user from test --- spec/models/key_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'spec/models') diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 6c06f5268b3..fcf2cb9f30d 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -49,10 +49,8 @@ describe Key do end context "validate it is a fingerprintable key" do - let(:user) { create(:user) } - it "accepts the fingerprintable key" do - build(:key, user: user).should be_valid + build(:key).should be_valid end it "rejects the unfingerprintable key (contains space in middle)" do -- cgit v1.2.1 From aa0473d0eb581a1c4d20be22c53ec4002a3801e0 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 17 Jul 2013 15:16:34 +0200 Subject: Validate fingerprint uniqueness --- spec/models/key_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'spec/models') diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index fcf2cb9f30d..f4dd726331a 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -42,10 +42,17 @@ describe Key do build(:key, user: user).should be_valid end - it "does not accepts the key twice" do + it "does not accept the exact same key twice" do create(:key, user: user) build(:key, user: user).should_not be_valid end + + it "does not accept a duplicate key with a different comment" do + create(:key, user: user) + duplicate = build(:key, user: user) + duplicate.key << ' extra comment' + duplicate.should_not be_valid + end end context "validate it is a fingerprintable key" do -- cgit v1.2.1