<commit_before>require File.dirname(__FILE__) + '/../../../test/test_helper'
require File.dirname(__FILE__) + '/../../spec_helper'
require 'admin/resources_controller'

# Re-raise errors caught by the controller.
class Admin::ResourcesController; def rescue_action(e) raise e end; end

describe Admin::ResourcesController do
  before do
    @request.session = { :user => users(:tobi).id }
  end

  def test_index
    get :index
    assert_response :success
    assert_template 'index'
    assert_template_has 'resources'
    assert_not_nil assigns(:resources)
    assert_not_nil assigns(:resources_pages)
  end

  def test_destroy
    res_id = resources(:resource1).id
    assert_not_nil Resource.find(res_id)

    get :destroy, :id => res_id
    assert_response :success
    assert_template 'destroy'
    assert_not_nil assigns(:file)

    post :destroy, :id => res_id
    response.should redirect_to(:action => 'index')
  end

  def test_new
    get :new
    assert_response :success
    assert_template 'new'
  end

  def test_upload<commit_msg>Removed testing of unexisting assigns(:resources_pages) due to will_paginate using only assigns(:resources).<commit_after>require File.dirname(__FILE__) + '/../../../test/test_helper'
require File.dirname(__FILE__) + '/../../spec_helper'
require 'admin/resources_controller'

# Re-raise errors caught by the controller.
class Admin::ResourcesController; def rescue_action(e) raise e end; end

describe Admin::ResourcesController do
  before do
    @request.session = { :user => users(:tobi).id }
  end

  def test_index
    get :index
    assert_response :success
    assert_template 'index'
    assert_template_has 'resources'
    assert_not_nil assigns(:resources)
  end

  def test_destroy
    res_id = resources(:resource1).id
    assert_not_nil Resource.find(res_id)

    get :destroy, :id => res_id
    assert_response :success
    assert_template 'destroy'
    assert_not_nil assigns(:file)

    post :destroy, :id => res_id
    response.should redirect_to(:action => 'index')
  end

  def test_new
    get :new
    assert_response :success
    assert_template 'new'
  end

  def test_upload
{'fraction_non_alphanumeric': 0.1015843429636533, 'fraction_numerical': 0.0009319664492078285, 'mean_word_length': 3.8795454545454544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '410237', 'n_tokens_mistral': 655, 'n_tokens_neox': 632, 'n_words': 169}