<commit_before># frozen_string_literal: true

require 'rails_helper'

describe Api::V1::Timelines::PublicController do
  render_views

  let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }

  before do
    allow(controller).to receive(:doorkeeper_token) { token }
  end

  context 'with a user context' do
    let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }

    describe 'GET #show' do
      before do
        PostStatusService.new.call(user.account, text: 'New status from user for federated public timeline.')
      end

      it 'returns http success' do
        get :show

        expect(response).to have_http_status(200)
        expect(response.headers['Link'].links.size).to eq(2)
      end
    end

    describe 'GET #show with local only' do
      before do
        PostStatusService.new.call(user.account, text: 'New status from user for local public timeline.')
      end

      it 'returns http success' do
        get :show, params: { local: true }

        expect(response).to have_http_status(200)
        expect(response.headers['Link'].links.size).to eq(2)
      end
    end
  end

  context 'without a user context' do
    let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }

    describe 'GET #show' do
      it 'returns http success' do
        get :show

        expect(response).to have_http_status(200)
        expect(response.headers['Link']).to be_nil
      end
    end
  end
end<commit_msg>Fix tests being broken because of different default setting<commit_after># frozen_string_literal: true

require 'rails_helper'

describe Api::V1::Timelines::PublicController do
  render_views

  let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }

  before do
    allow(controller).to receive(:doorkeeper_token) { token }
  end

  context 'with a user context' do
    let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }

    describe 'GET #show' do
      before do
        PostStatusService.new.call(user.account, text: 'New status from user for federated public timeline.')
      end

      it 'returns http success' do
        get :show

        expect(response).to have_http_status(200)
        expect(response.headers['Link'].links.size).to eq(2)
      end
    end

    describe 'GET #show with local only' do
      before do
        PostStatusService.new.call(user.account, text: 'New status from user for local public timeline.')
      end

      it 'returns http success' do
        get :show, params: { local: true }

        expect(response).to have_http_status(200)
        expect(response.headers['Link'].links.size).to eq(2)
      end
    end
  end

  context 'without a user context' do
    let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }

    before do
      Setting.timeline_preview = true
    end

    describe 'GET #show' do
      it 'returns http success' do
        get :show

        expect(response).to have_http_status(200)
        expect(response.headers['Link']).to be_nil
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09900353584056573, 'fraction_numerical': 0.007714561234329798, 'mean_word_length': 3.0051480051480053, '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': '5105359', 'n_tokens_mistral': 959, 'n_tokens_neox': 911, 'n_words': 266}