diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/gpg_spec.rb | 34 | ||||
-rw-r--r-- | spec/models/gpg_key_spec.rb | 8 |
2 files changed, 22 insertions, 20 deletions
diff --git a/spec/lib/gitlab/gpg_spec.rb b/spec/lib/gitlab/gpg_spec.rb index 2a55e7d89de..c0df719c0c2 100644 --- a/spec/lib/gitlab/gpg_spec.rb +++ b/spec/lib/gitlab/gpg_spec.rb @@ -28,37 +28,37 @@ describe Gitlab::Gpg do ).to eq [] end end +end + +describe Gitlab::Gpg::CurrentKeyChain, :gpg do + describe '.emails' do + it 'returns the emails' do + Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User2.public_key) + + expect( + described_class.emails(GpgHelpers::User2.fingerprint) + ).to match_array GpgHelpers::User2.emails + end + end - describe '.add_to_keychain', :gpg do + describe '.add', :gpg do it 'stores the key in the keychain' do expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq [] - Gitlab::Gpg.add_to_keychain(GpgHelpers::User1.public_key) + Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User1.public_key) expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).not_to eq [] end end - describe '.remove_from_keychain', :gpg do + describe '.remove', :gpg do it 'removes the key from the keychain' do - Gitlab::Gpg.add_to_keychain(GpgHelpers::User1.public_key) + Gitlab::Gpg::CurrentKeyChain.add(GpgHelpers::User1.public_key) expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).not_to eq [] - Gitlab::Gpg.remove_from_keychain(GpgHelpers::User1.fingerprint) + Gitlab::Gpg::CurrentKeyChain.remove(GpgHelpers::User1.fingerprint) expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq [] end end end - -describe Gitlab::Gpg::CurrentKeyChain, :gpg do - describe '.emails' do - it 'returns the emails' do - Gitlab::Gpg.add_to_keychain(GpgHelpers::User2.public_key) - - expect( - described_class.emails(GpgHelpers::User2.fingerprint) - ).to match_array GpgHelpers::User2.emails - end - end -end diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb index 889396c19c3..e8c41299937 100644 --- a/spec/models/gpg_key_spec.rb +++ b/spec/models/gpg_key_spec.rb @@ -24,17 +24,19 @@ describe GpgKey do describe 'add_to_keychain' do it 'calls add_to_keychain after create' do - expect(Gitlab::Gpg).to receive(:add_to_keychain).with(GpgHelpers::User1.public_key) + expect(Gitlab::Gpg::CurrentKeyChain).to receive(:add).with(GpgHelpers::User1.public_key) create :gpg_key end end describe 'remove_from_keychain' do it 'calls remove_from_keychain after destroy' do - allow(Gitlab::Gpg).to receive :add_to_keychain + allow(Gitlab::Gpg::CurrentKeyChain).to receive :add gpg_key = create :gpg_key - expect(Gitlab::Gpg).to receive(:remove_from_keychain).with(GpgHelpers::User1.fingerprint) + expect( + Gitlab::Gpg::CurrentKeyChain + ).to receive(:remove).with(GpgHelpers::User1.fingerprint) gpg_key.destroy! end |