<commit_before>require 'rails_helper'

module CitizenBudgetModel
  RSpec.describe TranslationsController, type: :controller do
    routes { CitizenBudgetModel::Engine.routes }

    describe 'when not signed in' do
      it 'redirects to sign in page' do
        get :index, {}
        expect(response).to redirect_to(new_user_session_path)
        post :create
        expect(response).to redirect_to(new_user_session_path)
      end
    end

    describe 'when signed in as regular user' do
      before(:each) do
        @request.env['devise.mapping'] = Devise.mappings[:user]
        sign_in CitizenBudgetModel::User.create!(email: '<EMAIL>', organization_id: 1)
      end

      describe 'GET index' do
        it 'returns http success' do
          get :index
          expect(response).to be_success
        end
      end

      describe 'GET create' do
        before(:all) do
          I18n.backend.store_translations('en-CA.en-CA', {'en-CA' => 'en-CA'}, escape: true)
        end

        it 'returns http success' do
          post :create, {pk: 'en-CA.en-CA', value: 'English'}
          expect(response.status).to eq(204)
        end

        it 'fails if parameters are missing' do
          post :create, {pk: 'en-CA.en-CA'}
          expect(response).to be_bad_request
          post :create, {value: 'English'}
          expect(response).to be_bad_request
        end

        it 'fails if key is invalid' do
          post :create, {pk: 'invalid', value: 'English'}
          expect(response).to be_bad_request
        end
      end
    end
  end
end
<commit_msg>fix locale for travis<commit_after>require 'rails_helper'

module CitizenBudgetModel
  RSpec.describe TranslationsController, type: :controller do
    routes { CitizenBudgetModel::Engine.routes }

    describe 'when not signed in' do
      it 'redirects to sign in page' do
        get :index, {}
        expect(response).to redirect_to(new_user_session_path)
        post :create
        expect(response).to redirect_to(new_user_session_path)
      end
    end

    describe 'when signed in as regular user' do
      before(:each) do
        @request.env['devise.mapping'] = Devise.mappings[:user]
        sign_in CitizenBudgetModel::User.create!(email: '<EMAIL>', organization_id: 1)
      end

      describe 'GET index' do
        it 'returns http success' do
          get :index
          expect(response).to be_success
        end
      end

      describe 'GET create' do
        before(:all) do
          I18n.backend.store_translations('en-CA', {'en-CA' => 'en-CA'}, escape: true)
        end

        it 'returns http success' do
          post :create, {pk: 'en-CA.en-CA', value: 'English'}
          expect(response.status).to eq(204)
        end

        it 'fails if parameters are missing' do
          post :create, {pk: 'en-CA.en-CA'}
          expect(response).to be_bad_request
          post :create, {value: 'English'}
          expect(response).to be_bad_request
        end

        it 'fails if key is invalid' do
          post :create, {pk: 'invalid', value: 'English'}
          expect(response).to be_bad_request
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10120177103099304, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 2.2675619834710745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1566107', 'n_tokens_mistral': 963, 'n_tokens_neox': 928, 'n_words': 269}