<commit_before>require 'rails_helper'

describe PagesController do
  let(:user) { instance_double('User', id: '1') }
  let(:default_language) { instance_double(Language, code: :en) }
  let(:language) { instance_double(Language, code: :fr) }
  let(:page) { instance_double('Page', active?: true, featured?: true, id: '1', liquid_layout: '3', secondary_liquid_layout: '4', language: default_language) }
  let(:renderer) { instance_double('LiquidRenderer', render: 'my rendered html', data: { some: 'data'}) }

  before do
    allow(request.env['warden']).to receive(:authenticate!) { user }
    allow(controller).to receive(:current_user) { user }
    allow_any_instance_of(ActionController::TestRequest).to receive(:location).and_return({})
  end

  describe 'GET #index' do
    it 'renders index' do
      get :index
      expect(response).to render_template('index')
    end
    it 'uses default localization' do
      expect(I18n.locale).to eq :en
    end
    it 'resets localization if a non-default localization is used' do
      I18n.locale = :fr
      get :index
      expect(I18n.locale).to eq :en
    end
  end

  describe 'POST #create' do<commit_msg>Combine the default locale spec into the index spec so it won't depend on the test order.<commit_after>require 'rails_helper'

describe PagesController do
  let(:user) { instance_double('User', id: '1') }
  let(:default_language) { instance_double(Language, code: :en) }
  let(:language) { instance_double(Language, code: :fr) }
  let(:page) { instance_double('Page', active?: true, featured?: true, id: '1', liquid_layout: '3', secondary_liquid_layout: '4', language: default_language) }
  let(:renderer) { instance_double('LiquidRenderer', render: 'my rendered html', data: { some: 'data'}) }

  before do
    allow(request.env['warden']).to receive(:authenticate!) { user }
    allow(controller).to receive(:current_user) { user }
    allow_any_instance_of(ActionController::TestRequest).to receive(:location).and_return({})
  end

  describe 'GET #index' do
    it 'renders index and uses default localization' do
      get :index
      expect(response).to render_template('index')
      expect(I18n.locale).to eq :en
    end
    it 'resets localization if a non-default localization is used' do
      I18n.locale = :fr
      get :index
      expect(I18n.locale).to eq :en
    end
  end

  describe 'POST #create' do
{'fraction_non_alphanumeric': 0.1319327731092437, 'fraction_numerical': 0.008403361344537815, 'mean_word_length': 4.338565022421525, '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': '3421259', 'n_tokens_mistral': 756, 'n_tokens_neox': 726, 'n_words': 205}