From 98531fc2487f8d4d7de47fe9a1d60c10d1f1d9ba Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Tue, 25 Jul 2017 16:23:52 +0200 Subject: [PATCH] upcase in the model instead of in the view --- app/models/gpg_key.rb | 8 ++++++++ app/models/gpg_signature.rb | 4 ++++ app/views/profiles/gpg_keys/_key.html.haml | 2 +- app/views/projects/commit/_signature_badge.html.haml | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index 47ebfc9d234..0d35baa7ade 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -37,6 +37,14 @@ class GpgKey < ActiveRecord::Base after_commit :update_invalid_gpg_signatures, on: :create after_commit :notify_user, on: :create + def primary_keyid + super&.upcase + end + + def fingerprint + super&.upcase + end + def key=(value) value.strip! unless value.blank? write_attribute(:key, value) diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb index 9ac89f0bbbf..cb69106183d 100644 --- a/app/models/gpg_signature.rb +++ b/app/models/gpg_signature.rb @@ -11,6 +11,10 @@ class GpgSignature < ActiveRecord::Base validates :project, presence: true validates :gpg_key_primary_keyid, presence: true + def gpg_key_primary_keyid + super&.upcase + end + def commit project.commit(commit_sha) end diff --git a/app/views/profiles/gpg_keys/_key.html.haml b/app/views/profiles/gpg_keys/_key.html.haml index d625aaea467..b04981f90e3 100644 --- a/app/views/profiles/gpg_keys/_key.html.haml +++ b/app/views/profiles/gpg_keys/_key.html.haml @@ -6,7 +6,7 @@ = render partial: 'email_with_badge', locals: { email: email, verified: verified } .description - %code= key.fingerprint.upcase + %code= key.fingerprint .pull-right %span.key-created-at created #{time_ago_with_tooltip(key.created_at)} diff --git a/app/views/projects/commit/_signature_badge.html.haml b/app/views/projects/commit/_signature_badge.html.haml index 51f04a11712..66f00eb5507 100644 --- a/app/views/projects/commit/_signature_badge.html.haml +++ b/app/views/projects/commit/_signature_badge.html.haml @@ -9,7 +9,7 @@ = content GPG Key ID: - %span.monospace= signature.gpg_key_primary_keyid.upcase + %span.monospace= signature.gpg_key_primary_keyid = link_to('Learn more about signing commits', help_page_path('workflow/gpg_signed_commits/index.md'), class: 'gpg-popover-help-link')