<commit_before>require File.expand_path('../../../app/interactors/create_conversation_with_message_interactor.rb', __FILE__)
require_relative 'interactor_spec_helper'

describe CreateConversationWithMessageInteractor do

  before do
    stub_classes'Commands::CreateConversation', 'Commands::CreateMessage',
                'Commands::CreateActivity', 'User'
  end

  describe '.execute' do
    it 'should work correctly' do
      graph_user   = mock();
      sender       = mock(:user, id: 13, username: 'jan',  graph_user: graph_user)
      receiver     = mock(:user, username: 'frank')
      content      = 'verhaal'
      usernames    = [sender.username, receiver.username]
      conversation = mock()
      fact_id = 10

      mixpanel = mock()
      options = {foo: 'bar', current_user: sender, mixpanel: mixpanel}

      mixpanel.should_receive(:track_event).with(:conversation_created)

      User.should_receive(:find).with(sender.id).and_return(sender)
      should_receive_new_with_and_receive_execute(
        Commands::CreateConversation, fact_id, usernames, options).and_return(conversation)
      should_receive_new_with_and_receive_execute(
        Commands::CreateMessage, sender.id, content, conversation, options)
      should_receive_new_with_and_receive_execute(
        Commands::CreateActivity, graph_user, :created_conversation, conversation, nil, options)

      CreateConversationWithMessageInteractor.perform fact_id, usernames, sender.id, content, options
    end
  end
end<commit_msg>removed nonsens<commit_after>require File.expand_path('../../../app/interactors/create_conversation_with_message_interactor.rb', __FILE__)
require_relative 'interactor_spec_helper'

describe CreateConversationWithMessageInteractor do

  before do
    stub_classes'Commands::CreateConversation', 'Commands::CreateMessage',
                'Commands::CreateActivity', 'User'
  end

  describe '.execute' do
    it 'should work correctly' do
      graph_user   = mock();
      sender       = mock(:user, id: 13, username: 'jan',  graph_user: graph_user)
      receiver     = mock(:user, username: 'frank')
      content      = 'verhaal'
      usernames    = [sender.username, receiver.username]
      conversation = mock()
      fact_id = 10

      mixpanel = mock()
      options = {current_user: sender, mixpanel: mixpanel}

      mixpanel.should_receive(:track_event).with(:conversation_created)

      User.should_receive(:find).with(sender.id).and_return(sender)
      should_receive_new_with_and_receive_execute(
        Commands::CreateConversation, fact_id, usernames, options).and_return(conversation)
      should_receive_new_with_and_receive_execute(
        Commands::CreateMessage, sender.id, content, conversation, options)
      should_receive_new_with_and_receive_execute(
        Commands::CreateActivity, graph_user, :created_conversation, conversation, nil, options)

      CreateConversationWithMessageInteractor.perform fact_id, usernames, sender.id, content, options
    end
  end
end
{'fraction_non_alphanumeric': 0.09748010610079576, 'fraction_numerical': 0.002652519893899204, 'mean_word_length': 4.096283783783784, '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': '6037384', 'n_tokens_mistral': 884, 'n_tokens_neox': 860, 'n_words': 166}