<commit_before>require 'test_helper'

class CommentsControllerTest < ActionController::TestCase
  def setup
    sign_in users(:one)
  end

  test "create valid" do
    post :create, :post_id => posts(:one), :comment => { :content => 'testing' }
    assert assigns(:post)
    assert assigns(:comment)
    assert_redirected_to "#{post_path(assigns(:post))}#comment#{assigns(:comment).id}"
  end
  
  test "flag comment" do
    comment = comments(:one)
    xhr :post, :flag, :id => comment
    assert assigns(:comment)
    assert_template 'flag'
  end

  test "like comment" do
    comment = comments(:one)
    xhr :post, :like, :id => comment
    assert assigns(:comment)
    assert_template 'like'
  end

  test "dislike comment" do
    comment = comments(:one)
    xhr :post, :dislike, :id => comment
    assert assigns(:comment)
    assert_template 'dislike'
  end

end<commit_msg>Improve comments controller tests<commit_after>require 'test_helper'

class CommentsControllerTest < ActionController::TestCase
  def setup
    sign_in users(:one)
  end

  test "create valid" do
    post :create, :post_id => posts(:one), :comment => { :content => 'testing' }
    assert assigns(:post)
    assert assigns(:comment)
    assert_redirected_to "#{post_path(assigns(:post))}#comment#{assigns(:comment).id}"
  end

  test "show comment" do
    comment = comments(:approved)
    get :show, :post_id => comment.post, :id => comment
    assert assigns(:post)
    assert assigns(:comment)
    assert_template 'show'
    assert_response :success
  end

  test "flag comment" do
    comment = comments(:one)
    xhr :post, :flag, :id => comment
    assert assigns(:comment)
    assert_template 'flag'
    assert_response :success
  end

  test "like comment" do
    comment = comments(:one)
    xhr :post, :like, :id => comment
    assert assigns(:comment)
    assert_template 'like'
    assert_response :success
  end

  test "dislike comment" do
    comment = comments(:one)
    xhr :post, :dislike, :id => comment
    assert assigns(:comment)
    assert_template 'dislike'
    assert_response :success
  end

end
{'fraction_non_alphanumeric': 0.11798287345385347, 'fraction_numerical': 0.0, 'mean_word_length': 3.7364864864864864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6191715', 'n_tokens_mistral': 661, 'n_tokens_neox': 640, 'n_words': 183}