<commit_before>require 'rails_helper'

module Socializer
  RSpec.describe People::ActivitiesController, type: :controller do
    routes { Socializer::Engine.routes }

    # Create a user and activities
    let(:user) { create(:socializer_person) }
    let(:activities) { Activity.person_stream(actor_uid: user.id, viewer_id: user.id).decorate }

    # 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, person_id: user
      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 @person' do
        expect(assigns(:person)).to match(user)
      end

      it 'assigns @title' do
        expect(assigns(:title)).to match(user.display_name)
      end

      it 'assigns @current_id' do
        expect(assigns(:current_id)).to eq(user.guid)
      end

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

module Socializer
  RSpec.describe People::ActivitiesController, type: :controller do
    routes { Socializer::Engine.routes }

    # Create a user and activities
    let(:user) { create(:socializer_person) }
    let(:activities) { Activity.person_stream(actor_uid: user.id, viewer_id: user.id).decorate }

    describe 'when not logged in' do
      describe 'GET #index' do
        it 'requires login' do
          get :index, person_id: user
          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, person_id: user
        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 @person' do
          expect(assigns(:person)).to match(user)
        end

        it 'assigns @title' do
          expect(assigns(:title)).to match(user.display_name)
        end

        it 'assigns @current_id' do
          expect(assigns(:current_id)).to eq(user.guid)
        end

        it 'assigns @activities' do
          expect(assigns(:activities)).to match_array(activities)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09287257019438445, 'fraction_numerical': 0.0, 'mean_word_length': 2.5673940949935816, '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': '5831217', 'n_tokens_mistral': 826, 'n_tokens_neox': 799, 'n_words': 223}