<commit_before>require 'spec_helper'

describe Api::DiagnosticDumpsController do
  let(:device) { FactoryBot.create(:device) }
  let(:user)   { FactoryBot.create(:user, device: device) }

  include Devise::Test::ControllerHelpers

  it 'lists all diagnostics' do
    sign_in user
    DiagnosticDump.destroy_all
    device_config = FactoryBot.create_list(:diagnostic_dump, 3, device: device)
    get :index
    expect(json.length).to eq(3)
    expect(json.pluck(:device_id).uniq).to eq([user.device.id])
  end

  it 'creates a dump' do
    sign_in user
    DiagnosticDump.destroy_all
    b4 = DiagnosticDump.count
    input = {
      fbos_version:      "123_fbos_version",
      fbos_commit:       "123_fbos_commit",
      firmware_commit:   "123_firmware_commit",
      network_interface: "123_network_interface",
      fbos_dmesg_dump:   "123_fbos_dmesg_dump",
      firmware_state:    "123_firmware_state",
    }
    post :create, body: input.to_json
    expect(response.status).to eq(200)
    expect(DiagnosticDump.count).to be > b4
    expect(DiagnosticDump.last.device).to eq(device)
    expect(json[:fbos_version]).to             eq("123_fbos_version")
    expect(json[:fbos_commit]).to              eq("123_fbos_commit")
    expect(json[:firmware_commit]).to          eq("123_firmware_commit")
    expect(json[:network_interface]).to        eq("123_network_interface")
    expect(json[:fbos_dmesg_dump]).to          eq("123_fbos_dmesg_dump")
    expect(json[:firmware_state]).to           eq("123_firmware_state")
    expect(json[:ticket_identifier].length).to eq(5)
  end

  it 'deletes' do
    sign_in user
    # DiagnosticDump.destroy_all
    device_config = FactoryBot.create(:diagnostic_dump, device: device)
    id            = device_config.id
    delete :destroy, params: { id: device_config.id }
    expect(response.status).to be(200)
    expect(DiagnosticDump.exists?(id)).to be false
  end
end
<commit_msg>:clap: Fix blinky test<commit_after>require 'spec_helper'

describe Api::DiagnosticDumpsController do
  let(:device) { FactoryBot.create(:device) }
  let(:user)   { FactoryBot.create(:user, device: device) }

  include Devise::Test::ControllerHelpers

  it 'lists all diagnostics' do
    sign_in user
    DiagnosticDump.destroy_all
    device_config = FactoryBot.create_list(:diagnostic_dump, 3, device: device)
    get :index
    expect(json.length).to eq(3)
    expect(json.pluck(:device_id).uniq).to eq([user.device.id])
  end

  it 'creates a dump' do
    sign_in user
    DiagnosticDump.destroy_all
    b4 = DiagnosticDump.count
    input = {
      fbos_version:      "123_fbos_version",
      fbos_commit:       "123_fbos_commit",
      firmware_commit:   "123_firmware_commit",
      network_interface: "123_network_interface",
      fbos_dmesg_dump:   "123_fbos_dmesg_dump",
      firmware_state:    "123_firmware_state",
    }
    post :create, body: input.to_json
    expect(response.status).to eq(200)
    expect(DiagnosticDump.count).to be > b4
    expect(DiagnosticDump.last.device).to eq(device)
    expect(json[:fbos_version]).to             eq("123_fbos_version")
    expect(json[:fbos_commit]).to              eq("123_fbos_commit")
    expect(json[:firmware_commit]).to          eq("123_firmware_commit")
    expect(json[:network_interface]).to        eq("123_network_interface")
    expect(json[:fbos_dmesg_dump]).to          eq("123_fbos_dmesg_dump")
    expect(json[:firmware_state]).to           eq("123_firmware_state")
    expect(json[:ticket_identifier].length).to be >= 4
  end

  it 'deletes' do
    sign_in user
    # DiagnosticDump.destroy_all
    device_config = FactoryBot.create(:diagnostic_dump, device: device)
    id            = device_config.id
    delete :destroy, params: { id: device_config.id }
    expect(response.status).to be(200)
    expect(DiagnosticDump.exists?(id)).to be false
  end
end

{'fraction_non_alphanumeric': 0.11401917595231925, 'fraction_numerical': 0.024358642135268203, 'mean_word_length': 3.519906323185012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7662153', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1279, 'n_words': 216}