<commit_before>require 'test_helper'

feature 'User Delete Account Page' do
  def setup
    @user = make_user
  end

  test 'that back- and delete-links are being shown correctly' do
    sign_in_as_user

    visit root_path

    assert page.text.include?("#{@user.name}")

    page.find("#dropdown-btn").click
    click_link 'Account settings'

    page.fill_in 'user_password', with: <PASSWORD>
    click_button 'Delete account'

    assert page.text.include?("Are you sure?")
    assert page.has_link?('No, go back!')
    assert page.has_link?('Yes, delete account!')
  end

  test 'that admins can not access the delete account page of other users' do
    admin = make_admin
    sign_in_as_admin

    visit delete_account_path(@user)

    assert page.text.include?("We're sorry. You don't have permission to access this page.")
  end

  test 'that no user can access the delete account page of other users' do
    user2 = make_user(email: '<EMAIL>')

    visit '/'
    click_link 'Sign in'

    fill_in 'Email', with: '<EMAIL>'
    fill_in 'Password', with: '<PASSWORD>'
    click_button 'Sign in'

    visit delete_account_path(@user)

    assert page.text.include?("We're sorry. You don't have permission to access this page.")
  end

  test 'that users can only access the delete account page via "Delete Account"-Button on their settings page' do
    sign_in_as_user

    visit delete_account_path(@user)

    assert page.text.include?("We're sorry. You don't have permission to access this page.")
  end
end<commit_msg>Fixes tests and includes the raised error<commit_after>require 'test_helper'

feature 'User Delete Account Page' do
  def setup
    @user = make_user
  end

  test 'that back- and delete-links are being shown correctly' do
    sign_in_as_user

    visit root_path

    assert page.text.include?("#{@user.name}")

    page.find("#dropdown-btn").click
    click_link 'Account settings'

    page.fill_in 'user_password', with: <PASSWORD>
    click_button 'Delete account'

    assert page.text.include?("Are you sure?")
    assert page.has_link?('No, go back!')
    assert page.has_link?('Yes, delete account!')
  end

  test 'that admins can not access the delete account page of other users' do
    admin = make_admin
    sign_in_as_admin

    assert_raises(ActionController::RoutingError) { visit delete_account_path(@user) }
  end

  test 'that no user can access the delete account page of other users' do
    user2 = make_user(email: '<EMAIL>')

    visit '/'
    click_link 'Sign in'

    fill_in 'Email', with: '<EMAIL>'
    fill_in 'Password', with: '<PASSWORD>'
    click_button 'Sign in'

    assert_raises(ActionController::RoutingError) { visit delete_account_path(@user) }
  end

  test 'that users can only access the delete account page via "Delete Account"-Button on their settings page' do
    sign_in_as_user

    assert_raises(ActionController::RoutingError) { visit delete_account_path(@user) }
  end
end
{'fraction_non_alphanumeric': 0.09728813559322035, 'fraction_numerical': 0.0006779661016949153, 'mean_word_length': 3.7140575079872202, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3514934', 'n_tokens_mistral': 922, 'n_tokens_neox': 887, 'n_words': 301}