<commit_before>require 'test_helper'

<% module_namespacing do -%>
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
  setup do
    @<%= singular_name %> = create(:<%= singular_name %>)
    sign_in create(:user)
  end

  test "index" do
    get :index
    assert_response :success
    assert_equal 1,json[:<%= plural_name %>].size
  end

  test "index with ids" do
    another = create(:<%= singular_name %>)
    get :index, ids: [ @<%= singular_name %>.id, another.id ]
    assert_response :success
    assert_equal 2,json[:<%= plural_name %>].size
  end

  test "create" do
    assert_difference('<%= model_class_name %>.count') do
      post :create, <%= "#{singular_name}: attributes_for(:#{singular_name})" %>

      assert_response :success, response.body.to_s
      assert_not_nil json[:<%=singular_name%>][:id], @<%= singular_name %>.id
    end
  end

  test "update" do
    patch :update, id: <%= "@#{singular_name}, #{singular_name}: attributes_for(:#{singular_name})" %>
    assert_response :success, response.body.to_s
  end

  test "destroy" do
    assert_difference('<%= model_class_name %>.count', -1) do
      delete :destroy, id: <%= "@#{singular_name}" %>
      assert_response :success, response.body.to_s
    end
  end
end
<% end -%><commit_msg>* admin tests compatible with friendly ID<commit_after>require 'test_helper'

<% module_namespacing do -%>
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
  setup do
    @<%= singular_name %> = create(:<%= singular_name %>)
    sign_in create(:user)
  end

  test "index" do
    get :index
    assert_response :success
    assert_equal 1,json[:<%= plural_name %>].size
  end

  test "index with ids" do
    another = create(:<%= singular_name %>)
    get :index, ids: [ @<%= singular_name %>.id, another.id ]
    assert_response :success
    assert_equal 2,json[:<%= plural_name %>].size
  end

  test "create" do
    assert_difference('<%= model_class_name %>.count') do
      post :create, <%= "#{singular_name}: attributes_for(:#{singular_name})" %>

      assert_response :success, response.body.to_s
      assert_not_nil json[:<%=singular_name%>][:id], @<%= singular_name %>.id
    end
  end

  test "update" do
    patch :update, id: <%= "@#{singular_name}.id, #{singular_name}: attributes_for(:#{singular_name})" %>
    assert_response :success, response.body.to_s
  end

  test "destroy" do
    assert_difference('<%= model_class_name %>.count', -1) do
      delete :destroy, id: <%= "@#{singular_name}" %>.id
      assert_response :success, response.body.to_s
    end
  end
end
<% end -%>
{'fraction_non_alphanumeric': 0.1599236641221374, 'fraction_numerical': 0.0022900763358778627, 'mean_word_length': 3.9734345351043645, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 35, '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': '130963', 'n_tokens_mistral': 925, 'n_tokens_neox': 845, 'n_words': 209}