<commit_before># frozen_string_literal: true
require 'rails_helper'

describe TrainingProgressManager do
  let(:user)     { create(:user) }
  # first and last slide
  let(:t_module) { TrainingModule.all.first }
  let(:slides)   { [t_module.slides.first, t_module.slides.last] }
  let(:slide)    { slides.first }
  let(:last_slide_completed) { slides.first.slug }
  let(:tmu) do
    create(:training_modules_users, user_id: user&.id, training_module_id: t_module.id,
                                    last_slide_completed: last_slide_completed,
                                    completed_at: completed_at)
  end
  let(:completed_at) { nil }
  let(:ids) { [t_module.id] }
  let(:week) { create(:week) }
  let!(:block) do
    create(:block, training_module_ids: ids, week_id: week.id)
  end

  before  { tmu }
  subject { described_class.new(user, t_module, slide) }

  describe '#slide_completed?' do
    context 'tmu is nil' do
      let(:tmu) { nil }
      it 'returns false' do
        expect(subject.slide_completed?).to eq(false)
      end
    end

    context 'last slide completed is nil' do
      let(:last_slide_completed) { nil }
      it 'returns false' do
        expect(subject.slide_completed?).to eq(false)
      end<commit_msg>Fix spec<commit_after># frozen_string_literal: true
require 'rails_helper'

describe TrainingProgressManager do
  let(:user)     { create(:user) }
  # first and last slide
  let(:t_module) { TrainingModule.all.first }
  let(:slides)   { [t_module.slides.first, t_module.slides.last] }
  let(:slide)    { slides.first }
  let(:last_slide_completed) { slides.first.slug }
  let(:tmu) do
    create(:training_modules_users, user_id: user&.id, training_module_id: t_module.id,
                                    last_slide_completed: last_slide_completed,
                                    completed_at: completed_at)
  end
  let(:completed_at) { nil }
  let(:ids) { [t_module.id] }
  let(:week) { create(:week, course: course) }
  let(:course) { create(:course) }
  let!(:block) do
    create(:block, training_module_ids: ids, week_id: week.id)
  end

  before  { tmu }
  subject { described_class.new(user, t_module, slide) }

  describe '#slide_completed?' do
    context 'tmu is nil' do
      let(:tmu) { nil }
      it 'returns false' do
        expect(subject.slide_completed?).to eq(false)
      end
    end

    context 'last slide completed is nil' do
      let(:last_slide_completed) { nil }
      it 'returns false' do
        expect(subject.slide_completed?).to eq(false)
      end
{'fraction_non_alphanumeric': 0.11662726556343578, 'fraction_numerical': 0.0, 'mean_word_length': 2.894171779141104, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6333963', 'n_tokens_mistral': 848, 'n_tokens_neox': 815, 'n_words': 182}