Skip to content
Snippets Groups Projects
Commit 7b7cd6f6 authored by Alexis Reigel's avatar Alexis Reigel
Browse files

add emails method to GgpKey

parent fbf1fd1a
No related branches found
No related tags found
No related merge requests found
Loading
@@ -21,6 +21,11 @@ class GpgKey < ActiveRecord::Base
Loading
@@ -21,6 +21,11 @@ class GpgKey < ActiveRecord::Base
write_attribute(:key, value) write_attribute(:key, value)
end end
   
def emails
raw_key = GPGME::Key.get(fingerprint)
raw_key.uids.map(&:email)
end
private private
   
def extract_fingerprint def extract_fingerprint
Loading
Loading
require_relative '../support/gpg_helpers'
FactoryGirl.define do
factory :gpg_key do
key GpgHelpers.public_key
end
end
Loading
@@ -38,4 +38,12 @@ describe GpgKey do
Loading
@@ -38,4 +38,12 @@ describe GpgKey do
expect(described_class.new(key: " #{key} ").key).to eq(key) expect(described_class.new(key: " #{key} ").key).to eq(key)
end end
end end
describe '#emails' do
it 'returns the emails from the gpg key' do
gpg_key = create :gpg_key
expect(gpg_key.emails).to match_array %w(mail@koffeinfrei.org lex@panter.ch)
end
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment