<commit_before># -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe AdminGeneralController do

  describe "when viewing front page of admin interface" do

    render_views
    before { basic_auth_login @request }

    it "should render the front page" do
      get :index
      expect(response).to render_template('index')
    end

  end

  describe 'when viewing the timeline' do

    it 'should assign an array of events in order of descending date to the view' do

      info_request = FactoryGirl.create(:info_request)
      public_body = FactoryGirl.create(:public_body)

      first_event = info_request.log_event('edit', {})
      public_body.name = 'Changed name'
      public_body.save!
      public_body_version = public_body.reverse_sorted_versions.first
      second_event = info_request.log_event('edit', {})

      get :timeline, :all => 1<commit_msg>Replace hash-based finder in admin_general_controller.<commit_after># -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe AdminGeneralController do

  describe "when viewing front page of admin interface" do

    it "should render the front page" do
      get :index
      expect(response).to render_template('index')
    end

    it 'assigns old unclassified requests' do
      InfoRequest.destroy_all
      @old_request = FactoryGirl.create(:old_unclassified_request)
      get :index
      expect(assigns[:old_unclassified]).to eq([@old_request])
    end

  end

  describe 'when viewing the timeline' do

    it 'should assign an array of events in order of descending date to the view' do

      info_request = FactoryGirl.create(:info_request)
      public_body = FactoryGirl.create(:public_body)

      first_event = info_request.log_event('edit', {})
      public_body.name = 'Changed name'
      public_body.save!
      public_body_version = public_body.reverse_sorted_versions.first
      second_event = info_request.log_event('edit', {})

      get :timeline, :all => 1
{'fraction_non_alphanumeric': 0.09365853658536585, 'fraction_numerical': 0.001951219512195122, 'mean_word_length': 3.5275938189845473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6980512', 'n_tokens_mistral': 604, 'n_tokens_neox': 572, 'n_words': 163}