<commit_before>require 'rails_helper'

describe Api::ProfilesController do
  describe '#show.json' do
    context 'authorized' do
      before { expect(subject).to receive(:verify_authorized).and_return(true) }

      let(:user) { double }

      before { expect(subject).to receive(:resource).and_return(user) }

      before { expect(subject).to receive(:authorize).with(user) }

      before { sign_in }

      before { get :show, format: :json }

      it { should render_template(:show) }

      it { should respond_with(:ok) }
    end

    context 'not authorized' do
      before { get :show, format: :json }

      it { should respond_with(:unauthorized) }
    end
  end

  # private methods

  describe '#resource' do
    context '@profile is set' do
      let(:profile) { double }

      before { subject.instance_variable_set(:@profile, profile) }<commit_msg>Improve tests<commit_after>require 'rails_helper'

describe Api::ProfilesController do
  describe '#show.json' do
    context 'authorized' do
      let(:user) { create(:user) }

      before { sign_in(user) }

      before { get :show, format: :json }

      it { should render_template(:show) }

      it { should respond_with(:ok) }
    end

    context 'not authorized' do
      before { get :show, format: :json }

      it { should respond_with(:unauthorized) }
    end
  end

  # private methods

  describe '#resource' do
    context '@profile is set' do
      let(:profile) { double }

      before { subject.instance_variable_set(:@profile, profile) }
{'fraction_non_alphanumeric': 0.11503267973856209, 'fraction_numerical': 0.0, 'mean_word_length': 3.028947368421053, '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': '818760', 'n_tokens_mistral': 464, 'n_tokens_neox': 439, 'n_words': 122}