<commit_before>require 'test_helper'

class UserSessionStoriesTest < ActionController::IntegrationTest
  def test_registration    
    # Try to access the account area without being logged in
    get account_url
    assert_redirected_to new_user_session_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "user_sessions/new"
    
    # Try to register with no info
    post account_url
    assert_template "users/new"
    
    # Register successfully
    post account_url, {:user => {:login => "binarylogic", :password => "<PASSWORD>", :confirm_password => "<PASSWORD>", :first_name => "Ben", :last_name => "Johnson"}}
    assert_redirected_to account_url
    assert flash.key?(:notice)
    
    access_account(User.find(2))
  end
  
  def test_login_process
    # Try to access the account area without being logged in
    get account_url
    assert_redirected_to new_user_session_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "user_sessions/new"
    
    login_unsuccessfully
    login_unsuccessfully("bjohnson", "<PASSWORD>")
    login_successfully("bjohnson", "benrocks")
    
    # Try to log in again after a successful login
    get new_user_session_url
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    # Try to register after a successful login
    get new_account_url
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    access_account
    logout(new_account_url) # before I tried to register, it stored my location
    
    # Try to access my account again
    get account_url
    assert_redirected_to new_user_session_url
    assert flash.key?(:notice)
  end
  
  def test_changing_password
    # Try logging in with correct credentials
    login_successfully("bjohnson", "benrocks")
    
    # Go to edit form
    get edit_account_path
    assert_template "users/edit"
    
    # Edit password
    put account_path, :user => {:login => "bjohnson", :password => "<PASSWORD>", :confirm_password => "<PASSWORD>", :first_name => "Ben", :last_name => "Johnson"}
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    access_account
    logout
    
    # Try to access my account again
    get account_url
    assert_redirected_to new_user_session_url
    assert flash.key?(:notice)
    
    login_successfully("bjohnson", "sillywilly")
    access_account
  end
end<commit_msg>Updated integration test<commit_after>require 'test_helper'

class UserSessionStoriesTest < ActionController::IntegrationTest
  def test_registration    
    # Try to access the account area without being logged in
    get account_url
    assert_redirected_to new_user_session_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "user_sessions/new"
    
    # Try to register with no info
    post account_url
    assert_template "users/new"
    
    # Register successfully
    post account_url, {:user => {:login => "binarylogic", :password => "<PASSWORD>", :confirm_password => "<PASSWORD>", :first_name => "Ben", :last_name => "Johnson"}}
    assert_redirected_to account_url
    assert flash.key?(:notice)
    
    access_account(User.last)
  end
  
  def test_login_process
    # Try to access the account area without being logged in
    get account_url
    assert_redirected_to new_user_session_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "user_sessions/new"
    
    login_unsuccessfully
    login_unsuccessfully("bjohnson", "badpassword")
    login_successfully("bjohnson", "benrocks")
    
    # Try to log in again after a successful login
    get new_user_session_url
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    # Try to register after a successful login
    get new_account_url
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    access_account
    logout(new_account_url) # before I tried to register, it stored my location
    
    # Try to access my account again
    get account_url
    assert_redirected_to new_user_session_url
    assert flash.key?(:notice)
  end
  
  def test_changing_password
    # Try logging in with correct credentials
    login_successfully("bjohnson", "benrocks")
    
    # Go to edit form
    get edit_account_path
    assert_template "users/edit"
    
    # Edit password
    put account_path, :user => {:login => "bjohnson", :password => "<PASSWORD>", :confirm_password => "<PASSWORD>", :first_name => "Ben", :last_name => "Johnson"}
    assert_redirected_to account_url
    follow_redirect!
    assert flash.key?(:notice)
    assert_template "users/show"
    
    access_account
    logout
    
    # Try to access my account again
    get account_url
    assert_redirected_to new_user_session_url
    assert flash.key?(:notice)
    
    login_successfully("bjohnson", "sillywilly")
    access_account
  end
end
{'fraction_non_alphanumeric': 0.07834012022493698, 'fraction_numerical': 0.00019391118867558658, 'mean_word_length': 3.5285338015803336, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 36, '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': '3951006', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1531, 'n_words': 401}