<commit_before>require 'spec_helper'

describe HomeController do
  render_views
  let(:distributor) { create(:distributor_enterprise) }

  before do
    controller.stub(:load_data_for_sidebar).and_return nil
    Enterprise.stub(:distributors_with_active_order_cycles).and_return [distributor]
    Enterprise.stub(:is_distributor).and_return [distributor]
  end
  it "sets active distributors" do
    get :index
    assigns[:active_distributors].should == [distributor]
  end
  
  # This is done inside the json/hubs RABL template
  it "gets the next order cycle for each hub" do
    OrderCycle.should_receive(:first_closing_for).with(distributor)
    get :index
  end
end
<commit_msg>Adding a spec for visiblity filtering<commit_after>require 'spec_helper'

describe HomeController do
  render_views
  let!(:distributor) { create(:distributor_enterprise) }
  let!(:invisible_distributor) { create(:distributor_enterprise, visible: false) }

  before do
    Enterprise.stub(:distributors_with_active_order_cycles).and_return [distributor]
  end

  it "sets active distributors" do
    get :index
    assigns[:active_distributors].should == [distributor]
  end

  it "does not show invisible hubs" do
    get :index
    response.body.should_not have_content invisible_distributor.name
  end
  
  # This is done inside the json/hubs RABL template
  it "gets the next order cycle for each hub" do
    OrderCycle.should_receive(:first_closing_for).with(distributor)
    get :index
  end
end

{'fraction_non_alphanumeric': 0.07806191117092867, 'fraction_numerical': 0.0, 'mean_word_length': 4.763565891472868, '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': '6706736', 'n_tokens_mistral': 484, 'n_tokens_neox': 455, 'n_words': 118}