<commit_before>require 'spec_helper'

describe EmploymentTribunalDecision do

  def employment_tribunal_decision_content_item(n)
    {
      "content_id" => SecureRandom.uuid,
      "base_path" => "/employment-tribunal-decisions/example-employment-tribunal-decision-#{n}",
      "title" => "Example Employment Tribunal Decision #{n}",
      "description" => "This is the summary of example Employment Tribunal Decision #{n}",
      "format" => "specialist_document",
      "publishing_app" => "specialist-publisher",
      "rendering_app" => "specialist-frontend",
      "locale" => "en",
      "phase" => "live",
      "public_updated_at" => "2015-11-16T11:53:30",
      "publication_state" => "draft",
      "details" => {
        "body" => "## Header" + ("\r\n\r\nThis is the long body of an example Employment Tribunal Decision" * 10),
        "metadata" => {
          "tribunal_decision_categories" => ["age-discrimination"],
          "tribunal_decision_country" => "england-and-wales",
          "tribunal_decision_decision_date" => "2015-07-30",
          "document_type" => "employment_tribunal_decision",
        },
        "change_history" => [],
      },
      "routes" => [
        {
          "path" => "/employment-tribunal-decisions/example-employment-tribunal-decision-#{n}",
          "type" => "exact",
        }
      ],
      "redirects" => [],
      "update_type" => "major",
    }
  end

  let(:non_employment_tribunal_decision_content_item) {
    {
      "content_id" => SecureRandom.uuid,
      "base_path" => "/other-documents/not-an-employment-tribunal-decision",
      "format" => "specialist_document",
      "details" => {
        "metadata" => {
          "document_type" => "not_an_employment_tribunal_decision",
        },
      },
    }
  }

  let(:employment_tribunal_decision_org_content_item) {
    {
      "base_path" => "/courts-tribunals/employment-tribunal",
      "content_id" => "8bb37087-a5a7-4493-8afe-900b36ebc927",
      "title" => "Employment Tribunal",
      "format" => "placeholder_organisation",
      "need_ids" => [],
      "locale" => "en",
      "updated_at" => "2015-08-20T10:26:56.082Z",
      "public_updated_at" => "2015-04-15T10:04:28.000+00:00",
      "phase" => "live",
      "analytics_identifier" => "CO1133",
      "links" => {
        "available_translations" => [
          {
            "content_id" => "1b5e08c8-ddde-4637-9375-f79e085ba6d5",
            "title" => "Employment tribunal decisions",
            "base_path" => "/employment-tribunal-decisions",
            "description" => nil,
            "api_url" => "https://www-origin.integration.publishing.service.gov.uk/api/content/employment-tribunal-decisions",
            "web_url" => "https://www-origin.integration.publishing.service.gov.uk/employment-tribunal-decisions",
            "locale" => "en"
          }
        ]
      },
      "description" => nil,
      "details" => {}
    }
  }

  let(:indexable_attributes) {
    {
      "title" => "Example Employment Tribunal Decision 0",
      "description" => "This is the summary of example Employment Tribunal Decision 0",
      "link" => "/employment-tribunal-decisions/example-employment-tribunal-decision-0",
      "indexable_content" => "## Header" + ("\r\n\r\nThis is the long body of an example Employment Tribunal Decision" * 10),
      "public_timestamp" => "2015-11-16T11:53:30+00:00",
      "tribunal_decision_categories" => ["age-discrimination"],
      "tribunal_decision_country" => "england-and-wales",
      "tribunal_decision_decision_date" => "2015-07-30",
      "organisations" => ["employment-tribunal"],
    }
  }

    let(:fields) { %i[base_path content_id] }

    let(:employment_tribunal_decisions) { 10.times.map { |n| employment_tribunal_decision_content_item(n) } }

    before do
     publishing_api_has_fields_for_format('specialist_document', employment_tribunal_decisions, fields)

    employment_tribunal_decisions.each do |decision|
      publishing_api_has_item(decision)
    end
<commit_msg>Fixed indentation in etd model spec<commit_after>require 'spec_helper'

describe EmploymentTribunalDecision do

  def employment_tribunal_decision_content_item(n)
    {
      "content_id" => SecureRandom.uuid,
      "base_path" => "/employment-tribunal-decisions/example-employment-tribunal-decision-#{n}",
      "title" => "Example Employment Tribunal Decision #{n}",
      "description" => "This is the summary of example Employment Tribunal Decision #{n}",
      "format" => "specialist_document",
      "publishing_app" => "specialist-publisher",
      "rendering_app" => "specialist-frontend",
      "locale" => "en",
      "phase" => "live",
      "public_updated_at" => "2015-11-16T11:53:30",
      "publication_state" => "draft",
      "details" => {
        "body" => "## Header" + ("\r\n\r\nThis is the long body of an example Employment Tribunal Decision" * 10),
        "metadata" => {
          "tribunal_decision_categories" => ["age-discrimination"],
          "tribunal_decision_country" => "england-and-wales",
          "tribunal_decision_decision_date" => "2015-07-30",
          "document_type" => "employment_tribunal_decision",
        },
        "change_history" => [],
      },
      "routes" => [
        {
          "path" => "/employment-tribunal-decisions/example-employment-tribunal-decision-#{n}",
          "type" => "exact",
        }
      ],
      "redirects" => [],
      "update_type" => "major",
    }
  end

  let(:non_employment_tribunal_decision_content_item) {
    {
      "content_id" => SecureRandom.uuid,
      "base_path" => "/other-documents/not-an-employment-tribunal-decision",
      "format" => "specialist_document",
      "details" => {
        "metadata" => {
          "document_type" => "not_an_employment_tribunal_decision",
        },
      },
    }
  }

  let(:employment_tribunal_decision_org_content_item) {
    {
      "base_path" => "/courts-tribunals/employment-tribunal",
      "content_id" => "8bb37087-a5a7-4493-8afe-900b36ebc927",
      "title" => "Employment Tribunal",
      "format" => "placeholder_organisation",
      "need_ids" => [],
      "locale" => "en",
      "updated_at" => "2015-08-20T10:26:56.082Z",
      "public_updated_at" => "2015-04-15T10:04:28.000+00:00",
      "phase" => "live",
      "analytics_identifier" => "CO1133",
      "links" => {
        "available_translations" => [
          {
            "content_id" => "1b5e08c8-ddde-4637-9375-f79e085ba6d5",
            "title" => "Employment tribunal decisions",
            "base_path" => "/employment-tribunal-decisions",
            "description" => nil,
            "api_url" => "https://www-origin.integration.publishing.service.gov.uk/api/content/employment-tribunal-decisions",
            "web_url" => "https://www-origin.integration.publishing.service.gov.uk/employment-tribunal-decisions",
            "locale" => "en"
          }
        ]
      },
      "description" => nil,
      "details" => {}
    }
  }

  let(:indexable_attributes) {
    {
      "title" => "Example Employment Tribunal Decision 0",
      "description" => "This is the summary of example Employment Tribunal Decision 0",
      "link" => "/employment-tribunal-decisions/example-employment-tribunal-decision-0",
      "indexable_content" => "## Header" + ("\r\n\r\nThis is the long body of an example Employment Tribunal Decision" * 10),
      "public_timestamp" => "2015-11-16T11:53:30+00:00",
      "tribunal_decision_categories" => ["age-discrimination"],
      "tribunal_decision_country" => "england-and-wales",
      "tribunal_decision_decision_date" => "2015-07-30",
      "organisations" => ["employment-tribunal"],
    }
  }

  let(:fields) { %i[base_path content_id] }

  let(:employment_tribunal_decisions) { 10.times.map { |n| employment_tribunal_decision_content_item(n) } }

  before do
    publishing_api_has_fields_for_format('specialist_document', employment_tribunal_decisions, fields)

    employment_tribunal_decisions.each do |decision|
      publishing_api_has_item(decision)
    end

{'fraction_non_alphanumeric': 0.15570202711105585, 'fraction_numerical': 0.03482153960950131, 'mean_word_length': 2.9596258000984736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 123, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '4765002', 'n_tokens_mistral': 2910, 'n_tokens_neox': 2609, 'n_words': 385}