<commit_before><commit_msg>refactored the Spinach feature `features/profile/emails.feature` into an rspec feature<commit_after>require 'rails_helper'

feature 'Profile > Emails' do
  let(:user) { create(:user) }

  before do
    login_as(user)
  end

  describe 'User adds an email' do
    before do
      visit profile_emails_path
    end

    scenario 'saves the new email' do
      fill_in('Email', with: '<EMAIL>')
      click_button('Add email address')

      expect(page).to have_content('<EMAIL> Unverified')
      expect(page).to have_content('<EMAIL> Verified')
      expect(page).to have_content('Resend Confirmation Email')
    end

    scenario 'does not add a duplicate email' do
      fill_in('Email', with: user.email)
      click_button('Add email address')

      email = user.emails.find_by(email: user.email)
      expect(email).to be_nil
      expect(page).to have_content('Email has already been taken')
    end
  end

  scenario 'User removes email' do
    user.emails.create(email: '<EMAIL>')
    visit profile_emails_path
    expect(page).to have_content("<EMAIL>")

    click_link('Remove')
    expect(page).to_not have_content("<EMAIL>")
  end

  scenario 'User confirms email' do
    email = user.emails.create(email: '<EMAIL>')
    visit profile_emails_path
    expect(page).to have_content("<EMAIL> Unverified")

    email.confirm
    expect(email.confirmed?).to be_truthy

    visit profile_emails_path
    expect(page).to have_content("<EMAIL> Verified")
  end

  scenario ''
end

{'fraction_non_alphanumeric': 0.11243386243386243, 'fraction_numerical': 0.0, 'mean_word_length': 3.6553846153846155, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, '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': '6703697', 'n_tokens_mistral': 489, 'n_tokens_neox': 476, 'n_words': 120}