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

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

class ManageTagsControllerTest < Test::Unit::TestCase

  def test_truth
    assert true
  end

#TODO i comment it because the test were not passing
#  fixtures :tags, :users, :blocks, :profiles, :virtual_communities, :boxes, :domains
#  def setup
#    @controller = ManageTagsController.new
#    @request    = ActionController::TestRequest.new
#    @response   = ActionController::TestResponse.new
#  end
#
#  # Replace this with your real tests.
#  def test_get_index
#    get :index
#    assert_response :redirect
#    assert_redirected_to :action => 'list'
#  end
#
#  def test_list
#    get :list
#    assert_response :success
#    assert_template 'list'
#    assert_not_nil assigns(:tags)
#    assert_not_nil assigns(:pending_tags)
#    assert_nil assigns(:parent), 'the list should not scoped'
#  end
#
#  def test_scoped_list
#    assert_nothing_raised { Tag.find(1) }
#    get :list, :parent => Tag.find(1)
#    assert_response :success
#    assert_template 'list'
#    assert_not_nil assigns(:parent), 'the list should be scoped'
#    assert_not_nil assigns(:tags)
#    assert_not_nil assigns(:pending_tags)
#  end
#
#  def test_new
#    get :new
#    assert_response :success
#    assert_template 'new'
#    assert_not_nil assigns(:parent_tags)
#    assert_not_nil assigns(:tag)
#  end
#
#  def test_create
#    post :create, :tag => {:name => 'test_tag'}
#    assert_response :redirect
#    assert_redirected_to :action => 'list'
#    assert_not_nil assigns(:tag)
#  end
#
#  def test_create_wrong
#    post :create, :tag => {:name => ''}
#    assert_response :success
#    assert_template 'new'
#  end
#
#  def test_edit
#    assert_nothing_raised { Tag.find(1) }
#    get :edit, :id => 1
#    assert assigns(:tag)
#    assert assigns(:parent_tags)
#  end
#
#  def test_update
#    assert_nothing_raised { Tag.find(1) }
#    post :update, :id => 1, :tag => {:name => 'altered_tag'}
#    assert_response :redirect
#    assert_redirected_to :action => 'list'
#    assert assigns(:tag)
#  end
#
#  def test_update_wrong
#    assert_nothing_raised { Tag.find(1) }
#    post :update, :id => 1, :tag => {:name => ''}
#    assert_response :success
#    assert_template 'edit'
#    assert assigns(:parent_tags)
#  end
#
#  def test_destroy
#    assert_nothing_raised { Tag.find(1) }
#    post :destroy, :id => 1
#    assert_response :redirect
#    assert_redirected_to :action => 'list'
#    assert_not_nil flash[:notice]
#    assert_raise(ActiveRecord::RecordNotFound) { Tag.find(1) }
#  end
#
#  def test_approve
#    assert_nothing_raised { Tag.find_with_pendings(4) }
#    assert Tag.find_with_pendings(4).pending?
#    post :approve, :id => 4
#    assert_response :redirect
#    assert_redirected_to :action => 'list'
#    assert ( not Tag.find_with_pendings(4).pending? )
#  end
end<commit_msg>ActionItem4: manage tags tests descommented<commit_after>require File.dirname(__FILE__) + '/../test_helper'
require 'manage_tags_controller'

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

class ManageTagsControllerTest < Test::Unit::TestCase

  def test_truth
    assert true
  end

#TODO i comment it because the test were not passing
  fixtures :tags, :users, :blocks, :profiles, :virtual_communities, :boxes, :domains
  def setup
    @controller = ManageTagsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end

  def test_get_index
    get :index
    assert_response :redirect
    assert_redirected_to :action => 'list'
  end

  def test_list
    get :list
    assert_response :success
    assert_template 'list'
    assert_not_nil assigns(:tags)
    assert_not_nil assigns(:pending_tags)
    assert_nil assigns(:parent), 'the list should not scoped'
  end

  def test_scoped_list
    assert_nothing_raised { Tag.find(1) }
    get :list, :parent => Tag.find(1)
    assert_response :success
    assert_template 'list'
    assert_not_nil assigns(:parent), 'the list should be scoped'
    assert_not_nil assigns(:tags)
    assert_not_nil assigns(:pending_tags)
  end

  def test_new
    get :new
    assert_response :success
    assert_template 'new'
    assert_not_nil assigns(:parent_tags)
    assert_not_nil assigns(:tag)
  end

  def test_create
    post :create, :tag => {:name => 'test_tag'}
    assert_response :redirect
    assert_redirected_to :action => 'list'
    assert_not_nil assigns(:tag)
  end

  def test_create_wrong
    post :create, :tag => {:name => ''}
    assert_response :success
    assert_template 'new'
  end

  def test_edit
    assert_nothing_raised { Tag.find(1) }
    get :edit, :id => 1
    assert assigns(:tag)
    assert assigns(:parent_tags)
  end

  def test_update
    assert_nothing_raised { Tag.find(1) }
    post :update, :id => 1, :tag => {:name => 'altered_tag'}
    assert_response :redirect
    assert_redirected_to :action => 'list'
    assert assigns(:tag)
  end

  def test_update_wrong
    assert_nothing_raised { Tag.find(1) }
    post :update, :id => 1, :tag => {:name => ''}
    assert_response :success
    assert_template 'edit'
    assert assigns(:parent_tags)
  end

  def test_destroy
    assert_nothing_raised { Tag.find(1) }
    post :destroy, :id => 1
    assert_response :redirect
    assert_redirected_to :action => 'list'
    assert_not_nil flash[:notice]
    assert_raise(ActiveRecord::RecordNotFound) { Tag.find(1) }
  end

  def test_approve
    assert_nothing_raised { Tag.find_with_pendings(4) }
    assert Tag.find_with_pendings(4).pending?
    post :approve, :id => 4
    assert_response :redirect
    assert_redirected_to :action => 'list'
    assert ( not Tag.find_with_pendings(4).pending? )
  end
end
{'fraction_non_alphanumeric': 0.11084865868061414, 'fraction_numerical': 0.005230302007761093, 'mean_word_length': 3.8470973017170893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '6431304', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1948, 'n_words': 477}