<commit_before>require 'spec_helper'

describe AuditRails::AuditsController do
  # Need to push this to spec/routing directory
  context 'routes' do
    it { expect(:get => "/audits").to route_to( 
      :controller => "audit_rails/audits", 
      :action => "index" )
    }
    
    it { expect(:post => "/audits").to route_to( 
      :controller => "audit_rails/audits", 
      :action => "create" )
    }

    it { expect(:get => "/audits/analytics").to route_to(
      :controller => "audit_rails/audits",
      :action => 'analytics'
      )
    }
  end

  context "GET index" do
    it "lists audits on page" do
      audits = (1..3).map {|t| FactoryGirl.create(:audit, user_name: 'Fake User', 
        description: "User logged on at #{t.days.ago}",
        action: 'login',
        controller: 'sessions')}

      get 'index'

      expect(assigns(:audits)).to eq(audits)
    end


    it "lists audits in excel" do
      audits = (1..3).map {|t| FactoryGirl.create(:audit, user_name: 'Fake User', 
        description: "User logged on at #{t.days.ago}",
        action: 'login',
        controller: 'sessions')}

      get 'index', format: 'xls'

      response.should be_success
      expect(assigns(:audits)).to eq(audits)<commit_msg>Fixed failing tests<commit_after>require 'spec_helper'

describe AuditRails::AuditsController do
  # Need to push this to spec/routing directory
  context 'routes' do
    it { expect(:get => "/audits").to route_to( 
      :controller => "audit_rails/audits", 
      :action => "index" )
    }
    
    it { expect(:post => "/audits").to route_to( 
      :controller => "audit_rails/audits", 
      :action => "create" )
    }

    it { expect(:get => "/audits/analytics").to route_to(
      :controller => "audit_rails/audits",
      :action => 'analytics'
      )
    }
  end

  context "GET index" do
    it "lists audits on page" do
      audits = (1..3).map {|t| AuditRails::Audit.create(user_name: 'Fake User', 
        description: "User logged on at #{t.days.ago}",
        action: 'login',
        controller: 'sessions')}

      get 'index'

      expect(assigns(:audits)).to eq(audits)
    end


    it "lists audits in excel" do
      audits = (1..3).map {|t| AuditRails::Audit.create(user_name: 'Fake User', 
        description: "User logged on at #{t.days.ago}",
        action: 'login',
        controller: 'sessions')}

      get 'index', format: 'xls'

      response.should be_success
      expect(assigns(:audits)).to eq(audits)
{'fraction_non_alphanumeric': 0.1508828250401284, 'fraction_numerical': 0.0032102728731942215, 'mean_word_length': 2.6078147612156295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2364761', 'n_tokens_mistral': 851, 'n_tokens_neox': 813, 'n_words': 205}