<commit_before>require 'spec_helper'

describe 'StatisticsConcern' do
  before do
    class FakeController < ActionController::Base
      include Statistics
    end
  end
  let(:fake_controller) { FakeController.new }

  it "gets stats for articles" do
    FactoryGirl.create_list(:article, 5)
    expect(fake_controller.get_stats_for(:articles)).to eq({ count: 5})
  end
    
  it "gets stats for projects" do
    FactoryGirl.create_list(:project, 5, status: 'active')
    FactoryGirl.create_list(:project, 3, status: 'disactivated')
    expect(fake_controller.get_stats_for(:projects)).to eq({ count: 5})
  end

  it "gets stats for members" do
    FactoryGirl.create_list(:user, 5)
    expect(fake_controller.get_stats_for(:members)).to eq({ count: 5})
  end

  it "gets stats for documents" do
    FactoryGirl.create_list(:document, 5)
    expect(fake_controller.get_stats_for(:documents)).to eq({ count: 5})
  end
end<commit_msg>FakeController global forcibly removed in teardown<commit_after>require 'spec_helper'

describe 'StatisticsConcern' do
  before :all do
    class FakeController < ActionController::Base
      include Statistics
    end
    @fake_controller = FakeController.new
  end

  it "gets stats for articles" do
    FactoryGirl.create_list(:article, 5)
    expect(@fake_controller.get_stats_for(:articles)).to eq({ count: 5})
  end
    
  it "gets stats for projects" do
    FactoryGirl.create_list(:project, 5, status: 'active')
    FactoryGirl.create_list(:project, 3, status: 'disactivated')
    expect(@fake_controller.get_stats_for(:projects)).to eq({ count: 5})
  end

  it "gets stats for members" do
    FactoryGirl.create_list(:user, 5)
    expect(@fake_controller.get_stats_for(:members)).to eq({ count: 5})
  end

  it "gets stats for documents" do
    FactoryGirl.create_list(:document, 5)
    expect(@fake_controller.get_stats_for(:documents)).to eq({ count: 5})
  end

  after :all do
    Object.send(:remove_const, :FakeController)
  end
end
{'fraction_non_alphanumeric': 0.11060606060606061, 'fraction_numerical': 0.00909090909090909, 'mean_word_length': 4.383152173913044, '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': '5890704', 'n_tokens_mistral': 652, 'n_tokens_neox': 604, 'n_words': 161}