<commit_before>require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the UsersHelper. For example:
#
# describe UsersHelper do
#   describe "string concat" do
#     it "concats two strings with spaces" do
#       expect(helper.concat_strings("this","that")).to eq("this that")
#     end
#   end
# end
RSpec.describe UsersHelper, type: :helper do
end<commit_msg>add user helper tests<commit_after>require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the UsersHelper. For example:
#
# describe UsersHelper do
#   describe "string concat" do
#     it "concats two strings with spaces" do
#       expect(helper.concat_strings("this","that")).to eq("this that")
#     end
#   end
# end
RSpec.describe UsersHelper, type: :helper do
  before(:each) do
    @user1= User.create!(username: Faker::Internet.user_name, password: "<PASSWORD>", first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, description: Faker::StarWars.quote, email: Faker::Internet.email, genres: Faker::Book.genre)
    @user2= User.create!(username: Faker::Internet.user_name, password: "<PASSWORD>", first_name: Faker::Name.first_name, last_name: Faker::Name.last_name, description: Faker::StarWars.quote, email: Faker::Internet.email, genres: Faker::Book.genre)
  end

  context '#current_user' do
    it 'finds the right user based on session' do
      session[:user_id] = @user1.id
      expect(current_user).to eq @user1
    end
  end

  context '#logged_in?' do
    it 'returns true if a user is logged in' do
      session[:user_id] = @user1.id
      expect(logged_in?).to be true
    end

    it 'returns true if a user is logged in' do
      expect(logged_in?).to be false
    end
  end

  context 'session_user' do
    it 'returns true if a user is logged in is the same as the user with params' do
      params[:id] = @user1.id
      session[:user_id] = @user1.id
      expect(session_user?).to be true
    end

  end

end
{'fraction_non_alphanumeric': 0.11161387631975868, 'fraction_numerical': 0.003519356460532931, 'mean_word_length': 3.877450980392157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1764958', 'n_tokens_mistral': 650, 'n_tokens_neox': 631, 'n_words': 206}