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 @@ ...@@ -2,26 +2,21 @@
require 'spec_helper' require 'spec_helper'
describe 'GPG signed commits', :js do describe 'GPG signed commits' do
let(:ref) { '2d1096e3a0ecf1d2baf6dee036cc80775d4940ba' }
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
it 'changes from unverified to verified when the user changes his email to match the gpg key' do 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' ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
project.add_maintainer(user) user = create(:user, email: 'unrelated.user@example.org')
perform_enqueued_jobs do perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end end
sign_in(user) visit project_commit_path(project, ref)
visit project_commits_path(project, ref) expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
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 # user changes his email which makes the gpg key verified
perform_enqueued_jobs do perform_enqueued_jobs do
...@@ -29,38 +24,30 @@ describe 'GPG signed commits', :js do ...@@ -29,38 +24,30 @@ describe 'GPG signed commits', :js do
user.update!(email: GpgHelpers::User1.emails.first) user.update!(email: GpgHelpers::User1.emails.first)
end end
visit project_commits_path(project, ref) visit project_commit_path(project, ref)
within '#commits-list' do expect(page).not_to have_content 'Unverified'
expect(page).to have_content 'Unverified' expect(page).to have_content 'Verified'
expect(page).to have_content 'Verified'
end
end end
it 'changes from unverified to verified when the user adds the missing gpg key' do it 'changes from unverified to verified when the user adds the missing gpg key' do
user = create :user, email: GpgHelpers::User1.emails.first ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
project.add_maintainer(user) user = create(:user, email: GpgHelpers::User1.emails.first)
sign_in(user) visit project_commit_path(project, ref)
visit project_commits_path(project, ref) expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
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 # user adds the gpg key which makes the signature valid
perform_enqueued_jobs do perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end end
visit project_commits_path(project, ref) visit project_commit_path(project, ref)
within '#commits-list' do expect(page).not_to have_content 'Unverified'
expect(page).to have_content 'Unverified' expect(page).to have_content 'Verified'
expect(page).to have_content 'Verified'
end
end end
context 'shows popover badges', :js do context 'shows popover badges', :js 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