<commit_before>require 'test_helper'

class CallsControllerTest < ActionController::TestCase
  include Devise::TestHelpers

  def setup
    @user = build :user
    sign_in @user
    @case = create :case
    @call = build :call
  end

  describe 'create method' do
    before do
      @call = attributes_for :call
    end

    it 'should create and save a new call' do
      assert_difference 'Case.find(@case).calls.count', 1 do
        post :create, status: @call.status, id: @case
      end
      assert_response :redirect
    end

    # If we have to look up the call through a case this test seems redundant
    # I.e. I think the previous test also confirms the association
    # it 'should associate the new call with a case' do
    #   post :create, status: @call.status, id: @case
    #   assert_equal Case.find(@case).calls.last.case, @case
    #   assert_includes Case.find(@case).calls, Case.find(@case).calls.last
    # end

    it 'should redirect to the root path afterwards' do
      post :create, status: @call.status, id: @case
      assert_redirected_to root_path
    end

    it 'should not save if status is blank for some reason' do
      assert_difference 'Case.find(@case).calls.count', 0 do
        post :create, status: nil, id: @case
      end
    end

    it 'should reject other attributes besides status' do
      post :create, status: @call.status, other: "extraneous attribute", id: @case
      assert_not_respond_to Case.find(@case).calls.last, :other
    end

  end

end<commit_msg>replace assert_difference 0 with assert_no_difference<commit_after>require 'test_helper'

class CallsControllerTest < ActionController::TestCase
  include Devise::TestHelpers

  def setup
    @user = build :user
    sign_in @user
    @case = create :case
    @call = build :call
  end

  describe 'create method' do
    before do
      @call = attributes_for :call
    end

    it 'should create and save a new call' do
      assert_difference 'Case.find(@case).calls.count', 1 do
        post :create, status: @call.status, id: @case
      end
      assert_response :redirect
    end

    # If we have to look up the call through a case this test seems redundant
    # I.e. I think the previous test also confirms the association
    # it 'should associate the new call with a case' do
    #   post :create, status: @call.status, id: @case
    #   assert_equal Case.find(@case).calls.last.case, @case
    #   assert_includes Case.find(@case).calls, Case.find(@case).calls.last
    # end

    it 'should redirect to the root path afterwards' do
      post :create, status: @call.status, id: @case
      assert_redirected_to root_path
    end

    it 'should not save if status is blank for some reason' do
      assert_no_difference 'Case.find(@case).calls.count' do
        post :create, status: nil, id: @case
      end
    end

    it 'should reject other attributes besides status' do
      post :create, status: @call.status, other: "extraneous attribute", id: @case
      assert_not_respond_to Case.find(@case).calls.last, :other
    end

  end

end
{'fraction_non_alphanumeric': 0.08697068403908795, 'fraction_numerical': 0.0013029315960912053, 'mean_word_length': 2.937179487179487, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2638205', 'n_tokens_mistral': 924, 'n_tokens_neox': 905, 'n_words': 336}