Commit c5271833 authored by Alexis Reigel's avatar Alexis Reigel

show gpg key's user info when no profile exists

parent cd01e828
...@@ -6,14 +6,26 @@ ...@@ -6,14 +6,26 @@
- content = capture do - content = capture do
- gpg_key = signature.gpg_key - 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 - if user
%div = link_to user_path(user), class: 'gpg-popover-user-link' do
= user_avatar_without_link(user: signature.gpg_key.user, size: 32) %div
= user_avatar_without_link(user: user, size: 32)
%div %div
%strong= gpg_key.user.username %strong= gpg_key.user.username
%div= gpg_key.user.name %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'] } - locals = { signature: signature, title: title, content: content, label: 'Verified', css_classes: ['valid'] }
......
...@@ -263,21 +263,25 @@ describe 'Commits' do ...@@ -263,21 +263,25 @@ describe 'Commits' do
end end
it 'shows popover badges', :js do it 'shows popover badges', :js do
user = create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard' gpg_user = create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard'
project.team << [user, :master]
Sidekiq::Testing.inline! do 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 end
user = create :user
project.team << [user, :master]
sign_in(user) sign_in(user)
visit namespace_project_commits_path(project.namespace, project, :'signed-commits') visit namespace_project_commits_path(project.namespace, project, :'signed-commits')
# unverified signature
click_on 'Unverified', match: :first click_on 'Unverified', match: :first
within '.popover' do within '.popover' do
expect(page).to have_content 'This commit was signed with an unverified signature.' 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}" expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}"
end end
# verified and the gpg user has a gitlab profile
click_on 'Verified' click_on 'Verified'
within '.popover' do within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature.' expect(page).to have_content 'This commit was signed with a verified signature.'
...@@ -285,6 +289,19 @@ describe 'Commits' do ...@@ -285,6 +289,19 @@ describe 'Commits' do
expect(page).to have_content 'Nannie Bernhard' expect(page).to have_content 'Nannie Bernhard'
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}" expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}"
end 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment