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

# Re-raise errors caught by the controller.
class SessionsController; def rescue_action(e) raise e end; end

class SessionsControllerTest < ActionController::TestCase
  # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
  # Then, you can remove it from this and the units test.
  include AuthenticatedTestHelper

  fixtures :users

  def setup
    @environment = create_environment(:is_default => true)
  #  Environment.expects(:default).returns(@environment)
  end

  def test_should_login_and_redirect
    user = create_user
    post :create, :login => user.login, :password => <PASSWORD>
    assert session[:user_id]
    assert_response :redirect
    assert_redirected_to survey_surveys_path

    user2 = create_user(:login => 'Susan', :administrator => true)
    post :create, :login => user2.login, :password => <PASSWORD>
    assert session[:user_id]
    assert_response :redirect
    assert_redirected_to admin_roles_path


  end

  def test_should_fail_login_and_not_redirect
    post :create, :login => 'quentin', :password => '<PASSWORD>'
    assert_nil session[:user_id]
    assert_response :success
  end

  def test_should_logout<commit_msg>Updating test. Fixing default route for non admin and changing default route for admin<commit_after>require File.dirname(__FILE__) + '/../test_helper'
require 'sessions_controller'

# Re-raise errors caught by the controller.
class SessionsController; def rescue_action(e) raise e end; end

class SessionsControllerTest < ActionController::TestCase
  # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
  # Then, you can remove it from this and the units test.
  include AuthenticatedTestHelper

  fixtures :users

  def setup
    @environment = create_environment(:is_default => true)
  #  Environment.expects(:default).returns(@environment)
  end

  def test_should_login_and_redirect
    user = create_user
    post :create, :login => user.login, :password => <PASSWORD>
    assert session[:user_id]
    assert_response :redirect
    assert_redirected_to public_index_url

    user2 = create_user(:login => 'Susan', :administrator => true)
    post :create, :login => user2.login, :password => <PASSWORD>
    assert session[:user_id]
    assert_response :redirect
    assert_redirected_to survey_surveys_path


  end

  def test_should_fail_login_and_not_redirect
    post :create, :login => 'quentin', :password => '<PASSWORD>'
    assert_nil session[:user_id]
    assert_response :success
  end

  def test_should_logout
{'fraction_non_alphanumeric': 0.08571428571428572, 'fraction_numerical': 0.0015238095238095239, 'mean_word_length': 4.696312364425163, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '4882077', 'n_tokens_mistral': 776, 'n_tokens_neox': 753, 'n_words': 214}