<commit_before>require 'rails_helper'

describe StudentJoinedClassroomWorker, type: :worker do
  let(:worker) { StudentJoinedClassroomWorker.new }
  let(:analytics) { SegmentAnalytics.new }
  let(:student) { create(:student) }
  let(:teacher) { create(:teacher) }

  it 'results in the sending of 2 segment.io events' do
    worker.perform(teacher.id, student.id)
    expect(analytics.backend.track_calls.size).to eq(2)
  end
end<commit_msg>added spec for student joined classroom worker<commit_after>require 'rails_helper'

describe StudentJoinedClassroomWorker, type: :worker do
  let(:worker) { described_class.new }
  let(:analyzer) { double(:analyzer, track_with_attributes: true, track: true) }
  let!(:student) { create(:student) }
  let!(:teacher) { create(:teacher) }

  before do
    allow(Analyzer).to receive(:new) { analyzer }
  end

  it 'results in the sending of 2 segment.io events' do
    expect(analyzer).to receive(:track_with_attributes).with(
      student,
      SegmentIo::Events::STUDENT_ACCOUNT_CREATION,
      {
        context: {:ip => student.ip_address },
        integrations: { intercom: 'false' }
      }
    )
    expect(analyzer).to receive(:track).with(teacher, SegmentIo::Events::TEACHERS_STUDENT_ACCOUNT_CREATION)
    worker.perform(teacher.id, student.id)
  end
end
{'fraction_non_alphanumeric': 0.12193251533742332, 'fraction_numerical': 0.0023006134969325155, 'mean_word_length': 4.553191489361702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3110753', 'n_tokens_mistral': 427, 'n_tokens_neox': 414, 'n_words': 88}