diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-09-30 01:55:36 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:25:27 +0300 |
commit | c50725fecfb776d56c95ef070940ca6c85786ecf (patch) | |
tree | 86695f75d9f3ef3595ed1970ccb960898098cba7 /app/models | |
parent | c2c35ae7971d19396078bdec6474fdd58f66000c (diff) |
Address feedback from last code review
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/gpg_key.rb | 5 | ||||
-rw-r--r-- | app/models/gpg_key_subkey.rb | 3 | ||||
-rw-r--r-- | app/models/gpg_signature.rb | 2 |
3 files changed, 9 insertions, 1 deletions
diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index 0ddf1245dd1..27513f4b03f 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -44,6 +44,7 @@ class GpgKey < ActiveRecord::Base def primary_keyid super&.upcase end + alias_method :keyid, :primary_keyid def fingerprint super&.upcase @@ -53,6 +54,10 @@ class GpgKey < ActiveRecord::Base super(value&.strip) end + def keyids + [keyid].concat(subkeys.map(&:keyid)) + end + def user_infos @user_infos ||= Gitlab::Gpg.user_infos_from_key(key) end diff --git a/app/models/gpg_key_subkey.rb b/app/models/gpg_key_subkey.rb index b4f146e5647..1f3ec2a8f68 100644 --- a/app/models/gpg_key_subkey.rb +++ b/app/models/gpg_key_subkey.rb @@ -9,6 +9,9 @@ class GpgKeySubkey < ActiveRecord::Base validates :gpg_key_id, presence: true validates :fingerprint, :keyid, presence: true, uniqueness: true + delegate :key, :user, :user_infos, :verified?, :verified_user_infos, + :verified_and_belongs_to_email?, to: :gpg_key + def keyid super&.upcase end diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb index c7f75288407..d3cca19cea8 100644 --- a/app/models/gpg_signature.rb +++ b/app/models/gpg_signature.rb @@ -24,7 +24,7 @@ class GpgSignature < ActiveRecord::Base def gpg_key=(model) case model when GpgKey then super - when GpgKeySubkey then write_attribute(:gpg_key_subkey_id, model.id) + when GpgKeySubkey then self.gpg_key_subkey = model end end |