<commit_before>require "spec_helper"

describe "Enqueueing jobs", type: :request do

  let(:job) { build_stubbed(:asyncapi_server_job, secret: "secret") }

  before do
    allow(Asyncapi::Server::Job).to receive(:create).with(
      class_name: "Runner",
      callback_url: "callback_url",
      params: {client: "params"}.to_json,
      secret: "secret",
    ).and_return(job)

    allow(job).to receive(:url).and_return("server_job_url")
  end

  it "allows asynchronous handing of http requests and cleans up old jobs" do
    expect(Asyncapi::Server::JobWorker).to receive(:perform_async).with(job.id)

    post("/tests", job: {
      callback_url: "callback_url",
      params: {client: "params"}.to_json,
      secret: "secret",
    })

    expect(response).to be_successful
    parsed_response = indifferent_hash(response.body)[:job]
    expect(parsed_response[:url]).to eq "server_job_url"
    expect(parsed_response[:secret]).to eq "secret"
  end

end<commit_msg>Fix typo<commit_after>require "spec_helper"

describe "Enqueueing jobs", type: :request do

  let(:job) { build_stubbed(:asyncapi_server_job, secret: "secret") }

  before do
    allow(Asyncapi::Server::Job).to receive(:create).with(
      class_name: "Runner",
      callback_url: "callback_url",
      params: {client: "params"}.to_json,
      secret: "secret",
    ).and_return(job)

    allow(job).to receive(:url).and_return("server_job_url")
  end

  it "allows asynchronous handling of http requests and cleans up old jobs" do
    expect(Asyncapi::Server::JobWorker).to receive(:perform_async).with(job.id)

    post("/tests", job: {
      callback_url: "callback_url",
      params: {client: "params"}.to_json,
      secret: "secret",
    })

    expect(response).to be_successful
    parsed_response = indifferent_hash(response.body)[:job]
    expect(parsed_response[:url]).to eq "server_job_url"
    expect(parsed_response[:secret]).to eq "secret"
  end

end
{'fraction_non_alphanumeric': 0.1402061855670103, 'fraction_numerical': 0.0, 'mean_word_length': 4.245945945945946, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1771190', 'n_tokens_mistral': 636, 'n_tokens_neox': 628, 'n_words': 130}