Ensure key fingerprints are generated correctly when modified

This commit is contained in:
Nick Thomas 2017-10-03 18:31:16 +01:00
parent 66dd045e6a
commit eaa1ce4fbe
No known key found for this signature in database
GPG Key ID: 2A313A47AFADACE9
2 changed files with 11 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class Key < ActiveRecord::Base
value&.delete!("\n\r")
value.strip! unless value.blank?
write_attribute(:key, value)
@public_key = nil
end
def publishable_key

View File

@ -155,5 +155,15 @@ describe Key, :mailer do
it 'strips white spaces' do
expect(described_class.new(key: " #{valid_key} ").key).to eq(valid_key)
end
it 'invalidates the public_key attribute' do
key = build(:key)
original = key.public_key
key.key = valid_key
expect(original.key_text).not_to be_nil
expect(key.public_key.key_text).to eq(valid_key)
end
end
end