show gpg key's user info when no profile exists

This commit is contained in:
Alexis Reigel 2017-07-13 16:04:19 +02:00
parent cd01e82873
commit c52718332c
2 changed files with 38 additions and 9 deletions

View file

@ -6,14 +6,26 @@
- content = capture do
- gpg_key = signature.gpg_key
- user = gpg_key&.user
- user_name = signature.gpg_key_user_name
- user_email = signature.gpg_key_user_email
= link_to user_path(gpg_key.user), class: 'gpg-popover-user-link' do
%div
= user_avatar_without_link(user: signature.gpg_key.user, size: 32)
- if user
= link_to user_path(user), class: 'gpg-popover-user-link' do
%div
= user_avatar_without_link(user: user, size: 32)
%div
%strong= gpg_key.user.username
%div= gpg_key.user.name
%div
%strong= gpg_key.user.username
%div= gpg_key.user.name
- else
= mail_to user_email do
%div
= user_avatar_without_link(user_name: user_name, user_email: user_email, size: 32)
%div
%strong= user_name
%div= user_email
- locals = { signature: signature, title: title, content: content, label: 'Verified', css_classes: ['valid'] }

View file

@ -263,21 +263,25 @@ describe 'Commits' do
end
it 'shows popover badges', :js do
user = create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard'
project.team << [user, :master]
gpg_user = create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard'
Sidekiq::Testing.inline! do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
create :gpg_key, key: GpgHelpers::User1.public_key, user: gpg_user
end
user = create :user
project.team << [user, :master]
sign_in(user)
visit namespace_project_commits_path(project.namespace, project, :'signed-commits')
# unverified signature
click_on 'Unverified', match: :first
within '.popover' do
expect(page).to have_content 'This commit was signed with an unverified signature.'
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}"
end
# verified and the gpg user has a gitlab profile
click_on 'Verified'
within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature.'
@ -285,6 +289,19 @@ describe 'Commits' do
expect(page).to have_content 'Nannie Bernhard'
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}"
end
# verified and the gpg user's profile doesn't exist anymore
gpg_user.destroy!
visit namespace_project_commits_path(project.namespace, project, :'signed-commits')
click_on 'Verified'
within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature.'
expect(page).to have_content 'Nannie Bernhard'
expect(page).to have_content 'nannie.bernhard@example.com'
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}"
end
end
end
end