<commit_before>require "rails_helper"

describe CommentsController do
  describe 'POST #create' do
    it 'adds a comment to the comments table'
    it 'does not save a comment without a body'
  end

  describe 'GET #edit' do
    it 'renders an edit form with original body text'
  end

  describe 'PUT #update' do
    it 'updates the comment in the comments table'
    it 'does not update a comment without a body'
  end

  describe 'DELETE #destroy' do
    it 'deletes the comment from the comments table'
    it 're-renders the same page after delete'
  end
end<commit_msg>Write tests for comments.<commit_after>require "rails_helper"

describe CommentsController do
  describe 'POST #create' do
    it 'adds a comment to the comments table' do
      expect{
        create(:q_comment)
        }.to change(Comment, :count).by(1)
    end

    it 'does not save a comment without a body' do
      expect{
        post :create, comment: attributes_for(:invalid_comment)
        }.to change(Comment, :count).by(0)
    end
  end

  describe 'GET #edit' do
    it 'assigns the requested comment to @comment' do
      comment = create(:q_comment)
      get :edit, id: comment.id
      expect(assigns(:comment)).to eq(comment)
    end

    it 'renders an edit form with original body text' do
      comment = create(:q_comment)
      get :edit, id: comment.id
      expect(response).to render_template :edit
    end
  end

  describe 'PATCH #update' do
    before :each do
      @question = create(:question, id: 1)
      @comment = create(:q_comment)
    end

    it 'updates the comment in the comments table' do
      patch :update, id: @comment, comment: attributes_for(:comment, body: "different!")
      @comment.reload
      expect(@comment.body).to eq("different!")
    end
  end
end
{'fraction_non_alphanumeric': 0.08622620380739082, 'fraction_numerical': 0.0016797312430011197, 'mean_word_length': 2.971111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '967932', 'n_tokens_mistral': 538, 'n_tokens_neox': 519, 'n_words': 209}