<commit_before>require "test_helper"

class CatalogAdmin::Categories::FieldsTest < ActionDispatch::IntegrationTest
  test "add an int field" do
    log_in_as("<EMAIL>", "password")
    visit("/one/admin")
    click_on("Category One")
    click_on("Int field")
    fill_in("field[name_en]", :with => "Test")
    fill_in("field[name_plural_en]", :with => "Tests")
    fill_in("Slug (singular)", :with => "test")
    fill_in("Minimum value (optional)", :with => 3)
    fill_in("Maximum value (optional)", :with => 50)

    assert_difference("categories(:one).fields.count") do
      click_on("Create field")
    end

    field = categories(:one).fields.where(:slug => "test").first!
    assert_equal(3, field.minimum.to_i)
    assert_equal(50, field.maximum.to_i)
  end

  test "edit a field" do
    log_in_as("<EMAIL>", "password")
    visit("/nested/admin")
    click_on("Bicycle")
    first("table a", :text => "Edit").click
    fill_in("field[name_en]", :with => "Changed!")
    fill_in("Slug", :with => "changed")

    assert_no_difference("Field.count") do
      click_on("Save field")
    end

    field = categories(:nested_bicycle).fields.where(:slug => "changed").first!
    assert_equal("Changed!", field.name)
  end

  test "delete a field" do
    log_in_as("<EMAIL>", "password")
    visit("/nested/admin")
    click_on("Bicycle")

    assert_difference("categories(:nested_bicycle).fields.count", -1) do
      first("table a", :text => "Delete").click
    end
  end
end
<commit_msg>CatAd::Categories namespace no longer exists<commit_after>require "test_helper"

class CatalogAdmin::CategoriesFieldsTest < ActionDispatch::IntegrationTest
  test "add an int field" do
    log_in_as("<EMAIL>", "password")
    visit("/one/admin")
    click_on("Category One")
    click_on("Int field")
    fill_in("field[name_en]", :with => "Test")
    fill_in("field[name_plural_en]", :with => "Tests")
    fill_in("Slug (singular)", :with => "test")
    fill_in("Minimum value (optional)", :with => 3)
    fill_in("Maximum value (optional)", :with => 50)

    assert_difference("categories(:one).fields.count") do
      click_on("Create field")
    end

    field = categories(:one).fields.where(:slug => "test").first!
    assert_equal(3, field.minimum.to_i)
    assert_equal(50, field.maximum.to_i)
  end

  test "edit a field" do
    log_in_as("<EMAIL>", "password")
    visit("/nested/admin")
    click_on("Bicycle")
    first("table a", :text => "Edit").click
    fill_in("field[name_en]", :with => "Changed!")
    fill_in("Slug", :with => "changed")

    assert_no_difference("Field.count") do
      click_on("Save field")
    end

    field = categories(:nested_bicycle).fields.where(:slug => "changed").first!
    assert_equal("Changed!", field.name)
  end

  test "delete a field" do
    log_in_as("<EMAIL>", "password")
    visit("/nested/admin")
    click_on("Bicycle")

    assert_difference("categories(:nested_bicycle).fields.count", -1) do
      first("table a", :text => "Delete").click
    end
  end
end

{'fraction_non_alphanumeric': 0.1724709784411277, 'fraction_numerical': 0.004643449419568822, 'mean_word_length': 4.10321489001692, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '3136340', 'n_tokens_mistral': 1028, 'n_tokens_neox': 988, 'n_words': 204}