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

describe Queries::UsersByGraphUserIds do
  before do
    stub_classes "GraphUser", "User"
  end

  it 'throws when initialized with a argument that is not an integer' do
    expect { Queries::UsersByGraphUserIds.new ['g6'] }.
      to raise_error(RuntimeError, 'id should be a positive integer.')
  end

  describe ".execute" do
    it "should work with an empty list of ids" do
      fake_user = mock()

      should_receive_new_with_and_receive_execute(
          Queries::UsersByIds, [], {}).and_return([])

      Queries::UsersByGraphUserIds.any_instance.stub(authorized?: true)

      result = Queries::UsersByGraphUserIds.execute([])

      expect(result).to eq([])
    end

    it "should work with multiple ids" do
      graph_users = [mock(user_id: 4), mock(user_id: 5), mock(user_id: 6)]
      gu_ids = [1, 2, 3]

      gu_ids.each_with_index do |graph_user_id, index|
        GraphUser.should_receive(:[]).with(graph_user_id).and_return(graph_users[index])
      end<commit_msg>removed unused mock<commit_after>require File.expand_path('../../../../app/interactors/queries/users_by_graph_user_ids.rb', __FILE__)
require_relative '../interactor_spec_helper'

describe Queries::UsersByGraphUserIds do
  before do
    stub_classes "GraphUser", "User"
  end

  it 'throws when initialized with a argument that is not an integer' do
    expect { Queries::UsersByGraphUserIds.new ['g6'] }.
      to raise_error(RuntimeError, 'id should be a positive integer.')
  end

  describe ".execute" do
    it "should work with an empty list of ids" do
      should_receive_new_with_and_receive_execute(
          Queries::UsersByIds, [], {}).and_return([])

      Queries::UsersByGraphUserIds.any_instance.stub(authorized?: true)

      result = Queries::UsersByGraphUserIds.execute([])

      expect(result).to eq([])
    end

    it "should work with multiple ids" do
      graph_users = [mock(user_id: 4), mock(user_id: 5), mock(user_id: 6)]
      gu_ids = [1, 2, 3]

      gu_ids.each_with_index do |graph_user_id, index|
        GraphUser.should_receive(:[]).with(graph_user_id).and_return(graph_users[index])
      end
{'fraction_non_alphanumeric': 0.12138475021910605, 'fraction_numerical': 0.006134969325153374, 'mean_word_length': 3.7463617463617465, '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': '826826', 'n_tokens_mistral': 754, 'n_tokens_neox': 723, 'n_words': 175}