<commit_before>require 'test_helper'

# FunderTest contains the model tests for a Funder
class FunderTest < ActiveSupport::TestCase

  def setup
    @funder = Funder.create(name: '<NAME>',
                            address: 'Example Address',
                            url: 'https://www.example.com',
                            description: 'Example Description',
                            email: '<EMAIL>',
                            telephone: '0123456789')
  end

  test 'should be valid' do
    assert @funder.valid?
  end

  test 'name should be present' do
    @funder.name = ''
    assert_not @funder.valid?
  end

  test "email shouldn't be too long" do
    @funder.email = 'a' * 256
    assert_not @funder.valid?
  end

  test "telephone shouldn't be too long" do
    @funder.telephone = '0' * 256
    assert_not @funder.valid?
  end

  test "address shouldn't be too long" do
    @funder.address = 'a' * 256
    assert_not @funder.valid?
  end

  test "description shouldn't be too long" do
    @funder.description = 'a' * 65_537
    assert_not @funder.valid?
  end

end<commit_msg>Add test for index on name and email for a funder.<commit_after>require 'test_helper'

# FunderTest contains the model tests for a Funder
class FunderTest < ActiveSupport::TestCase

  def setup
    @funder = Funder.create(name: '<NAME>',
                            address: 'Example Address',
                            url: 'https://www.example.com',
                            description: 'Example Description',
                            email: '<EMAIL>',
                            telephone: '0123456789')
  end

  test 'should be valid' do
    assert @funder.valid?
  end

  test 'name should be present' do
    @funder.name = ''
    assert_not @funder.valid?
  end

  test "email shouldn't be too long" do
    @funder.email = 'a' * 256
    assert_not @funder.valid?
  end

  test "telephone shouldn't be too long" do
    @funder.telephone = '0' * 256
    assert_not @funder.valid?
  end

  test "address shouldn't be too long" do
    @funder.address = 'a' * 256
    assert_not @funder.valid?
  end

  test "description shouldn't be too long" do
    @funder.description = 'a' * 65_537
    assert_not @funder.valid?
  end

  test 'index on name and email' do
    @duplicate_funder = @funder.dup
    assert_not @duplicate_funder.valid?
    assert @duplicate_funder.name == @funder.name
    assert @duplicate_funder.email == @funder.email
    assert_no_difference 'Funder.count' do
      @duplicate_funder.save
    end
  end

end
{'fraction_non_alphanumeric': 0.09653270291568164, 'fraction_numerical': 0.019700551615445233, 'mean_word_length': 2.2098609355246523, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5985790', 'n_tokens_mistral': 837, 'n_tokens_neox': 778, 'n_words': 236}