<commit_before># -*- encoding : utf-8 -*-
require 'spec_helper'

describe InterventionsController do

  setup(:activate_authlogic)

  context "an user logged in" do

    before(:each) do
      login
    end

    let(:fireman) { make_fireman_with_grades(:station => @station) }

    describe "GET :index" do

      before(:each) do
        get :index
      end

      it { should respond_with(:success) }
      it { should render_template("index") }
      it { should render_with_layout("back") }

      it { expect(assigns(:interventions)).to_not be_nil}
    end

    describe "GET :stats with interventions" do

      before(:each) do
        i = make_intervention_with_firemen(:station => @station)
        allow_any_instance_of(Station).to receive(:interventions).and_return(double(:latest => {:first => i}))
        allow_any_instance_of(Intervention).to receive(:years_stats).and_return([Date.today.year+1, Date.today.year])
      end

      describe "GET :stats with bad year" do

        before(:each) do
          get :stats, :year => (Date.today.year-1).to_s, :type => 'by_month'
        end

        it { should redirect_to(interventions_stats_path((Date.today.year), 'by_month')) }
      end

      describe "GET :stats with bad type" do

        before(:each) do
          get :stats, :year => Date.today.year.to_s, :type => 'by_badtype'
        end
<commit_msg>Fix tests for interventions stats.<commit_after># -*- encoding : utf-8 -*-
require 'spec_helper'

describe InterventionsController do

  setup(:activate_authlogic)

  context "an user logged in" do

    before(:each) do
      login
    end

    let(:fireman) { make_fireman_with_grades(:station => @station) }

    describe "GET :index" do

      before(:each) do
        get :index
      end

      it { should respond_with(:success) }
      it { should render_template("index") }
      it { should render_with_layout("back") }

      it { expect(assigns(:interventions)).to_not be_nil}
    end

    describe "GET :stats with interventions" do

      before(:each) do
        i = make_intervention_with_firemen(:station => @station)
        allow_any_instance_of(Station).to receive(:interventions).and_return(double(:latest => {:first => i}))
        allow(Intervention).to receive(:years_stats).and_return([Date.today.year, Date.today.year+1])
      end

      describe "GET :stats with bad year" do

        before(:each) do
          get :stats, :year => (Date.today.year-1).to_s, :type => 'by_month'
        end

        it { should redirect_to(interventions_stats_path((Date.today.year), 'by_month')) }
      end

      describe "GET :stats with bad type" do

        before(:each) do
          get :stats, :year => Date.today.year.to_s, :type => 'by_badtype'
        end

{'fraction_non_alphanumeric': 0.12386487468216491, 'fraction_numerical': 0.002179440610243371, 'mean_word_length': 2.857142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '972463', 'n_tokens_mistral': 874, 'n_tokens_neox': 820, 'n_words': 204}