<commit_before># frozen_string_literal: true

require 'spec_helper'

describe 'GPG signed commits', :js do
  let(:ref) { '2d1096e3a0ecf1d2baf6dee036cc80775d4940ba' }
  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: '<EMAIL>'
    project.add_maintainer(user)

    perform_enqueued_jobs do
      create :gpg_key, key: GpgHelpers::User1.public_key, user: user
    end

    sign_in(user)

    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
      user.skip_reconfirmation!
      user.update!(email: GpgHelpers::User1.emails.first)
    end

    visit project_commits_path(project, ref)

    within '#commits-list' do
      expect(page).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)

    sign_in(user)

    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)

    within '#commits-list' do
      expect(page).to have_content 'Unverified'
      expect(page).to have_content 'Verified'
    end
  end
<commit_msg>Simplify "changes to verified" GPG feature specs<commit_after># frozen_string_literal: true

require 'spec_helper'

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
    ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
    user = create(:user, email: '<EMAIL>')

    perform_enqueued_jobs do
      create :gpg_key, key: GpgHelpers::User1.public_key, user: user
    end

    visit project_commit_path(project, ref)

    expect(page).to have_content 'Unverified'
    expect(page).not_to have_content 'Verified'

    # user changes his email which makes the gpg key verified
    perform_enqueued_jobs do
      user.skip_reconfirmation!
      user.update!(email: GpgHelpers::User1.emails.first)
    end

    visit project_commit_path(project, ref)

    expect(page).not_to have_content 'Unverified'
    expect(page).to have_content 'Verified'
  end

  it 'changes from unverified to verified when the user adds the missing gpg key' do
    ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
    user = create(:user, email: GpgHelpers::User1.emails.first)

    visit project_commit_path(project, ref)

    expect(page).to have_content 'Unverified'
    expect(page).not_to have_content 'Verified'

    # 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_commit_path(project, ref)

    expect(page).not_to have_content 'Unverified'
    expect(page).to have_content 'Verified'
  end

{'fraction_non_alphanumeric': 0.08407974573822595, 'fraction_numerical': 0.008668015024559377, 'mean_word_length': 3.8487394957983194, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6327938', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1112, 'n_words': 309}