<commit_before>require 'integration_helper'

describe 'Reserving a username', type: :request do

  it 'should get success note with valid username' do
    visit '/'

    fill_in 'user_username', with: random_username
    fill_in 'user_email',    with: random_email

    click_button 'Reserve'

    page.should have_content('You have successfully reserved your username!')
  end

  it 'should get failure note with invalid username' do
    visit '/'

    fill_in 'user_username', with: 'teh_user_has_a_way_too_long_username'
    fill_in 'user_email',    with: random_email

    click_button 'Reserve'

    page.should have_content('Registration failed')
  end

  it 'should make the username appear in the reserved user list' do
    username = random_username

    visit '/'

    fill_in 'user_username', with: username
    fill_in 'user_email',    with: random_email

    click_button 'Reserve'

    create_admin_and_login

    within(:css, 'a.dropdown-toggle') do
      page.should have_content('Admin')
    end

    visit '/a/users/reserved'

    within(find("#main-wrapper table tr>td", text: username).parent) do
      page.should_not have_content('confirmed')
    end
  end

  it 'user should receive a confirmation email and should be able to confirm its e-mail address' do
    email = random_email

    clear_emails

    visit '/'

    fill_in 'user_username', with: random_username
    fill_in 'user_email',    with: email

    click_button 'Reserve'

    open_email email

    current_email.click_link 'Confirm my email address'

    page.should have_content "Email confirmed. Awaiting account approval."
  end
end<commit_msg>fixed some stuff about the specs<commit_after>require 'integration_helper'

describe 'Reserving a username', type: :request do

  it 'should get success note with valid username' do
    visit '/'
    disable_html5_validations(page)

    fill_in 'top_registration_form_user_username', with: random_username
    fill_in 'top_registration_form_user_email',    with: random_email

    click_button 'Reserve my username'

    page.should have_content("Great, you’re almost finished! Please click the confirmation link in the email we’ve sent you.")
  end

  it 'should get failure note with invalid username' do
    visit '/'
    disable_html5_validations(page)

    fill_in 'top_registration_form_user_username', with: 'teh_user_has_a_way_too_long_username'
    fill_in 'top_registration_form_user_email',    with: random_email

    click_button 'Reserve my username'

    page.should have_content('Registration failed')
  end

  it 'should make the username appear in the reserved user list' do
    username = random_username

    visit '/'
    disable_html5_validations(page)

    fill_in 'top_registration_form_user_username', with: username
    fill_in 'top_registration_form_user_email',    with: random_email

    click_button 'Reserve my username'

    create_admin_and_login

    within(:css, 'a.dropdown-toggle') do
      page.should have_content('Admin')
    end

    visit '/a/users/reserved'

    within(find("#main-wrapper table tr>td", text: username).parent) do
      page.should_not have_content('confirmed')
    end
  end

  it 'user should receive a confirmation email and should be able to confirm its e-mail address' do
    clear_emails

    visit '/'
    disable_html5_validations(page)

    fill_in 'top_registration_form_user_username', with: random_username
    fill_in 'top_registration_form_user_email',    with: email

    click_button 'Reserve my username'

    email = random_email
    open_email email

    current_email.click_link 'Confirm my email address'

    page.should have_content "Email confirmed. Awaiting account approval."
  end
end
{'fraction_non_alphanumeric': 0.0728744939271255, 'fraction_numerical': 0.0010796221322537112, 'mean_word_length': 3.831812255541069, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6981457', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1063, 'n_words': 329}