<commit_before>require 'test_helper'

class GetHisotyTest < ActionDispatch::IntegrationTest
  def setup
    @user = users(:nona)
    @other = users(:other)
    @user_token = api_keys(:nonas).access_token
    @other_token = api_keys(:others).access_token
  end

  test "send yo and get history" do
    post yo_path(@other), { format: :json }, { "X-API-TOKEN": @user_token }
    get history_path, { format: :json }, { "X-API-TOKEN": @other_token }
    assert_response :ok
    json = response_json
    assert { json["count"] == 1 }
    assert { not json["history"].nil? }
    assert { json["history"].count == 1 }
    assert { json["history"][0]["user"] == @user.name }
    assert { not json["history"][0]["yoed_at"].nil? }
  end

  test "get history(limit)" do
    10.times do
      post yo_path(@other), { format: :json }, { "X-API-TOKEN": @user_token }
    end
    get history_path, { format: :json, limit: 5 }, { "X-API-TOKEN": @other_token }
    assert_response :ok<commit_msg>get history test(use limit and page)<commit_after>require 'test_helper'

class GetHisotyTest < ActionDispatch::IntegrationTest
  def setup
    @user = users(:nona)
    @other = users(:other)
    @user_token = api_keys(:nonas).access_token
    @other_token = api_keys(:others).access_token
  end

  test "send yo and get history" do
    post yo_path(@other), { format: :json }, { "X-API-TOKEN": @user_token }
    get history_path, { format: :json }, { "X-API-TOKEN": @other_token }
    assert_response :ok
    json = response_json
    assert { json["count"] == 1 }
    assert { not json["history"].nil? }
    assert { json["history"].count == 1 }
    assert { json["history"][0]["user"] == @user.name }
    assert { not json["history"][0]["yoed_at"].nil? }
  end

  test "get history(limit)" do
    10.times do
      post yo_path(@other), { format: :json }, { "X-API-TOKEN": @user_token }
    end
    get history_path, { format: :json, limit: 5 }, { "X-API-TOKEN": @other_token }
    assert_response :ok
    json = response_json
    assert { json["count"] == 5 }
    assert { not json["history"].nil? }
    assert { json["history"].count == 5 }
    5.times do |i|
      assert { json["history"][i]["user"] == @user.name }
      assert { not json["history"][i]["yoed_at"].nil? }
    end
  end

  test "get history(limit and page)" do
    25.times do
      post yo_path(@other), { format: :json }, { "X-API-TOKEN": @user_token }
    end
    get history_path, { format: :json, limit: 10, page: 3 }, { "X-API-TOKEN": @other_token }
    assert_response :ok
{'fraction_non_alphanumeric': 0.166073546856465, 'fraction_numerical': 0.008699090549624358, 'mean_word_length': 3.3771626297577853, 'pattern_counts': {'":': 10, '<': 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': '4314920', 'n_tokens_mistral': 876, 'n_tokens_neox': 865, 'n_words': 209}