<commit_before>require 'rails_helper'

module Socializer
  RSpec.describe Circles::ContactsController, type: :controller do
    routes { Socializer::Engine.routes }

    # Create a user and a contact
    let(:user) { create(:socializer_person) }
    let(:contacts) { user.contacts }

    # Setting the current user
    before { cookies[:user_id] = user.guid }

    it { should use_before_action(:authenticate_user) }

    describe 'GET #index' do
      before :each do
        get :index
      end

      it 'returns http success' do
        expect(response).to have_http_status(:success)
      end

      it 'renders the :index template' do
        expect(response).to render_template :index
      end

      it 'assigns @contacts' do
        expect(assigns(:contacts)).to match_array(contacts)
      end
    end<commit_msg>Circles::ContactsController: begin testing when not logged in<commit_after>require 'rails_helper'

module Socializer
  RSpec.describe Circles::ContactsController, type: :controller do
    routes { Socializer::Engine.routes }

    # Create a user and a contact
    let(:user) { create(:socializer_person) }
    let(:contacts) { user.contacts }

    describe 'when not logged in' do
      describe 'GET #index' do
        it 'requires login' do
          get :index
          expect(response).to redirect_to root_path
        end
      end
    end

    describe 'when logged in' do
      # Setting the current user
      before { cookies[:user_id] = user.guid }

      it { should use_before_action(:authenticate_user) }

      describe 'GET #index' do
        before :each do
          get :index
        end

        it 'returns http success' do
          expect(response).to have_http_status(:success)
        end

        it 'renders the :index template' do
          expect(response).to render_template :index
        end

        it 'assigns @contacts' do
          expect(assigns(:contacts)).to match_array(contacts)
        end
      end
    end
{'fraction_non_alphanumeric': 0.0840080971659919, 'fraction_numerical': 0.0, 'mean_word_length': 2.5366726296958855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2768344', 'n_tokens_mistral': 573, 'n_tokens_neox': 554, 'n_words': 167}