<commit_before>require "rails_helper"

RSpec.describe Api::LearnController,
               type: :request do
  let!(:user_test) {
    create :content_learning_test,
           user: current_user
  }
  let(:current_user) {
    create :user, role: :cliente
  }

  let(:endpoint) {
    "/api/learn"
  }

  before { login_as current_user }

  before { create :achievement }

  let(:json_response) {
    JSON.parse response.body
  }

  let(:params) {
    {
      test_id: user_test.id,
      answers: response_answers.to_json
    }
  }

  let(:response_answers) {
    valid_count = 0
    user_test.questions.map do |question|
      {
        content_id: question["content_id"],
        answer_id: question["possible_answers"].detect { |possible_answer|
          if valid_count < 3
            valid_count += 1
            possible_answer["correct"]
          end<commit_msg>Fix unit tests<commit_after>require "rails_helper"

RSpec.describe Api::LearnController,
               type: :request do
  let!(:user_test) {
    create :content_learning_test,
           user: current_user
  }
  let(:current_user) {
    create :user, role: :cliente
  }

  let(:endpoint) {
    "/api/learn"
  }

  before { login_as current_user }

  before { create :achievement }

  before {
    create :neuron,
    title: "Lenguaje"

    create :neuron,
    title: "Artes"

    create :neuron,
    title: "Aprender"

    create :neuron,
    title: "Naturaleza"
  }

  let(:json_response) {
    JSON.parse response.body
  }

  let(:params) {
    {
      test_id: user_test.id,
      answers: response_answers.to_json
    }
  }

  let(:response_answers) {
    valid_count = 0
    user_test.questions.map do |question|
      {
        content_id: question["content_id"],
        answer_id: question["possible_answers"].detect { |possible_answer|
          if valid_count < 3
            valid_count += 1
            possible_answer["correct"]
          end
{'fraction_non_alphanumeric': 0.10897768552153607, 'fraction_numerical': 0.0031136481577581734, 'mean_word_length': 2.4184397163120566, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5101154', 'n_tokens_mistral': 660, 'n_tokens_neox': 625, 'n_words': 120}