<commit_before>require File.dirname(__FILE__) + '/../test_helper'
require 'account_controller'

# Raise errors beyond the default web-based presentation
class AccountController; def rescue_action(e) raise e end; end

class AccountControllerTest < Test::Unit::TestCase
  
  fixtures :users
  
  def setup
    @controller = AccountController.new
    @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
    @request.host = "localhost"
  end
  
  def test_auth_rolf
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :login, "user_login" => "rolf", "user_password" => "<PASSWORD>"
    assert(@response.has_session_object?("user"))

    assert_equal @rolf, @response.session["user"]
    
    assert_equal("http://localhost/bogus/location", @response.redirect_url)
  end
  
  def test_signup
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :signup, "user" => { "login" => "newbob", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>",
                              "email" => "<EMAIL>", "theme" => "NULL" }
    assert(@response.has_session_object?("user"))
    
    assert_equal("http://localhost/bogus/location", @response.redirect_url)
  end

  def test_bad_signup
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :signup, "user" => { "login" => "newbob", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:password))
    
    post :signup, "user" => { "login" => "yo", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:login))

    post :signup, "user" => { "login" => "yo", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:password))<commit_msg>Fixed failing tests due to unrecognized email address.<commit_after>require File.dirname(__FILE__) + '/../test_helper'
require 'account_controller'

# Raise errors beyond the default web-based presentation
class AccountController; def rescue_action(e) raise e end; end

class AccountControllerTest < Test::Unit::TestCase
  
  fixtures :users
  
  def setup
    @controller = AccountController.new
    @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
    @request.host = "localhost"
  end
  
  def test_auth_rolf
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :login, "user_login" => "rolf", "user_password" => "<PASSWORD>"
    assert(@response.has_session_object?("user"))

    assert_equal @rolf, @response.session["user"]
    
    assert_equal("http://localhost/bogus/location", @response.redirect_url)
  end
  
  def test_signup
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :signup, "user" => { "login" => "newbob", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>",
                              "email" => "<EMAIL>", "theme" => "NULL" }
    assert(@response.has_session_object?("user"))
    
    assert_equal("http://localhost/bogus/location", @response.redirect_url)
  end

  def test_bad_signup
    @request.session['return-to'] = "http://localhost/bogus/location"

    post :signup, "user" => { "login" => "newbob", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:password))
    
    post :signup, "user" => { "login" => "yo", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:login))

    post :signup, "user" => { "login" => "yo", "password" => "<PASSWORD>", "password_confirmation" => "<PASSWORD>" }
    assert(find_record_in_template("user").errors.invalid?(:password))
{'fraction_non_alphanumeric': 0.17345631565462466, 'fraction_numerical': 0.0, 'mean_word_length': 4.5375886524822695, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 63, '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': '516595', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1202, 'n_words': 222}