<commit_before>scope do
  setup do
    @email          = Settings::API_TEST_USERNAME
    @user           = User.new :email => @email
    @password       = Settings::API_TEST_PASSWORD
    @cf_description = "Cloud Foundry sponsored by Pivotal"
  end

  test "Should be able to login against CF api" do
    assert @user.login :username => @email,
    :password => <PASSWORD>
  end

  test "Should be able to get info from cloudfoundry" do
    assert @user.client.info[:description] == @cf_description
  end

  test "authenticates should login to CF api and return a User obj" do
    user = User.authenticate @email, @password
    assert user.email == @email
  end

  test "should create local user when succesfully logged in" do
    User.find(:email => @email).first.delete
    users_count_before_login = User.all.size

    User.authenticate @email, @password
    assert User.all.size == users_count_before_login + 1
  end

  test "should store the token and use it to get a client and avoid re-login" do
    User.authenticate @email, @password
    user = User.find(:email => @email).first

    assert user.client.spaces
  end

  test 'should return avatar url'do
    user = User.new :email => '<EMAIL>'
    assert user.avatar_file == "a7d174ed732e7799e762a184d5213193.png"
  end

  test 'should cache the CFoundry client after first called to avoid extra requests'do 
    User.clear_client_cache!
    
    assert User.clients.empty? 

    user = User.new :email => @email
    user.client

    assert User.clients.size == 1
  end
  
  test 'authenticates against a different api' do 
    User.find(:email => @email).first.delete
    user = User.new :email => @email, :api_url => 'custom_api.cf.com'
    assert User.authenticate(user.email, @password)
  end  

  test 'user client should use custom api provided by the user when data is valid' do 
    user = User.new :email => @email, :api_url => 'custom_api.cf.com'
    
    assert user.client.target == user.endpoint
  end

 end<commit_msg>User model test descriptions refactored<commit_after>scope do
  setup do
    @email          = Settings::API_TEST_USERNAME
    @user           = User.new :email => @email
    @password       = Settings::API_TEST_PASSWORD
    @cf_description = "Cloud Foundry sponsored by Pivotal"
  end

  # User
  test "It logs in with valid data and valid endpoint" do
    assert @user.login :username => @email,
    :password => @password
  end

  test "It gets info from cloudfoundry" do
    assert @user.client.info[:description] == @cf_description
  end

  # User#authenticate
  test "It authenticates with valid data and returns an object" do
    user = User.authenticate @email, @password
    assert user.email == @email
  end

  test "Creates a DB record when logs in for first time" do
    User.find(:email => @email).first.delete
    users_count_before_login = User.all.size

    User.authenticate @email, @password
    assert User.all.size == users_count_before_login + 1
  end

  test "Stores client tokens" do
    User.authenticate @email, @password
    user = User.find(:email => @email).first

    assert user.client.spaces
  end

  test 'Creates a hash to fetch a gravatar' do
    user = User.new :email => '<EMAIL>'
    assert user.avatar_file == "a7d174ed732e7799e762a184d5213193.png"
  end

  test 'Caches the authenticated CFoundry client object' do
    User.clear_client_cache!

    assert User.clients.empty?

    user = User.new :email => @email
    user.client

    assert User.clients.size == 1
  end

  test 'Authenticates against a different api' do
    User.find(:email => @email).first.delete
    user = User.new :email => @email, :api_url => 'custom_api.cf.com'
    assert User.authenticate(user.email, @password)
  end

  test 'After login with custom api CF client uses custom api' do
    user = User.new :email => @email, :api_url => 'custom_api.cf.com'

    assert user.client.target == user.endpoint
  end

 end
{'fraction_non_alphanumeric': 0.09517734115845879, 'fraction_numerical': 0.013268690992600153, 'mean_word_length': 3.1350210970464136, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 30, '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': '1747195', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1191, 'n_words': 391}