<commit_before>require File.dirname(__FILE__) + '/../../test_helper'
require 'admin/categories_controller'

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

class Admin::CategoriesControllerTest < Test::Unit::TestCase
  fixtures :categories, :users

  def setup
    @controller = Admin::CategoriesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new

    @request.session = { :user => @tobi }
  end

  def test_index
    get :index
    assert_rendered_file 'list'
  end

  def test_list
    get :list
    assert_rendered_file 'list'
    assert_template_has 'categories'
  end

  def test_create
    num_categories = Category.find_all.size

    post :new, 'category' => { :name => "test category" }
    assert_redirected_to :action => 'list'

    assert_equal num_categories + 1, Category.find_all.size
  end

  def test_edit<commit_msg>added back test_show for categories, whoops<commit_after>require File.dirname(__FILE__) + '/../../test_helper'
require 'admin/categories_controller'

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

class Admin::CategoriesControllerTest < Test::Unit::TestCase
  fixtures :categories, :users

  def setup
    @controller = Admin::CategoriesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new

    @request.session = { :user => @tobi }
  end

  def test_index
    get :index
    assert_rendered_file 'list'
  end

  def test_list
    get :list
    assert_rendered_file 'list'
    assert_template_has 'categories'
  end
  
  def test_show
    get :show, 'id' => 1
    assert_rendered_file 'show'
    assert_template_has 'category'
    assert_valid_record 'category'
  end

  def test_create
    num_categories = Category.find_all.size

    post :new, 'category' => { :name => "test category" }
    assert_redirected_to :action => 'list'

    assert_equal num_categories + 1, Category.find_all.size
  end

  def test_edit
{'fraction_non_alphanumeric': 0.09548447789275635, 'fraction_numerical': 0.0014111006585136407, 'mean_word_length': 3.912240184757506, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '2136219', 'n_tokens_mistral': 654, 'n_tokens_neox': 623, 'n_words': 163}