Commit ee172686 authored by Robert Speicher's avatar Robert Speicher

Simplify "changes to verified" GPG feature specs

Previously, we wasted time creating a maintainer and signing them in,
then loaded the entire commit list just to verify the GPG status of a
single commit.

Now, we rely on the project being public so no user needs to be
authenticated, and load just the page for the commit we care about.
parent 8afd0381
......@@ -2,26 +2,21 @@
require 'spec_helper'
describe 'GPG signed commits', :js do
let(:ref) { '2d1096e3a0ecf1d2baf6dee036cc80775d4940ba' }
describe 'GPG signed commits' do
let(:project) { create(:project, :public, :repository) }
it 'changes from unverified to verified when the user changes his email to match the gpg key' do
user = create :user, email: 'unrelated.user@example.org'
project.add_maintainer(user)
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
user = create(:user, email: 'unrelated.user@example.org')
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
sign_in(user)
visit project_commit_path(project, ref)
visit project_commits_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
end
# user changes his email which makes the gpg key verified
perform_enqueued_jobs do
......@@ -29,39 +24,31 @@ describe 'GPG signed commits', :js do
user.update!(email: GpgHelpers::User1.emails.first)
end
visit project_commits_path(project, ref)
visit project_commit_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Unverified'
expect(page).to have_content 'Verified'
end
end
it 'changes from unverified to verified when the user adds the missing gpg key' do
user = create :user, email: GpgHelpers::User1.emails.first
project.add_maintainer(user)
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
user = create(:user, email: GpgHelpers::User1.emails.first)
sign_in(user)
visit project_commit_path(project, ref)
visit project_commits_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
end
# user adds the gpg key which makes the signature valid
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
visit project_commits_path(project, ref)
visit project_commit_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Unverified'
expect(page).to have_content 'Verified'
end
end
context 'shows popover badges', :js do
let(:user_1) do
......
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