<commit_before>require "test_helper"

class Admin::EditorialRemarksControllerTest < ActionController::TestCase
  setup do
    @logged_in_user = login_as :departmental_editor
  end

  should_be_an_admin_controller

  test "should render the document title and body to give context to the person rejecting" do
    document = create(:submitted_edition, title: "document-title", body: "document-body")
    get :new, document_id: document

    assert_select "#{record_css_selector(document)} .title", text: "document-title"
    assert_select "#{record_css_selector(document)} .body", text: "document-body"
  end

  test "should redirect to the list of documents that need work" do
    document = create(:submitted_edition)
    post :create, document_id: document, editorial_remark: { body: "editorial-remark-body" }
    assert_redirected_to admin_documents_path(state: :submitted)
  end

  test "should create an editorial remark" do
    document = create(:submitted_edition)
    post :create, document_id: document, editorial_remark: { body: "editorial-remark-body" }

    document.reload
    assert_equal 1, document.editorial_remarks.length
    assert_equal @logged_in_user, document.editorial_remarks.first.author
    assert_equal "editorial-remark-body", document.editorial_remarks.first.body
  end

  test "should explain why the editorial remark couldn't be saved" do
    document = create(:submitted_edition)
    post :create, document_id: document, editorial_remark: { body: "" }
    assert_template "new"
    assert_select ".form-errors"
  end
end<commit_msg>Rename variables in editorial_remarks_controller_test.<commit_after>require "test_helper"

class Admin::EditorialRemarksControllerTest < ActionController::TestCase
  setup do
    @logged_in_user = login_as :departmental_editor
  end

  should_be_an_admin_controller

  test "should render the edition title and body to give context to the person rejecting" do
    edition = create(:submitted_edition, title: "edition-title", body: "edition-body")
    get :new, document_id: edition

    assert_select "#{record_css_selector(edition)} .title", text: "edition-title"
    assert_select "#{record_css_selector(edition)} .body", text: "edition-body"
  end

  test "should redirect to the list of editions that need work" do
    edition = create(:submitted_edition)
    post :create, document_id: edition, editorial_remark: { body: "editorial-remark-body" }
    assert_redirected_to admin_documents_path(state: :submitted)
  end

  test "should create an editorial remark" do
    edition = create(:submitted_edition)
    post :create, document_id: edition, editorial_remark: { body: "editorial-remark-body" }

    edition.reload
    assert_equal 1, edition.editorial_remarks.length
    assert_equal @logged_in_user, edition.editorial_remarks.first.author
    assert_equal "editorial-remark-body", edition.editorial_remarks.first.body
  end

  test "should explain why the editorial remark couldn't be saved" do
    edition = create(:submitted_edition)
    post :create, document_id: edition, editorial_remark: { body: "" }
    assert_template "new"
    assert_select ".form-errors"
  end
end
{'fraction_non_alphanumeric': 0.08796443315338202, 'fraction_numerical': 0.0006351222610352493, 'mean_word_length': 4.932203389830509, 'pattern_counts': {'":': 0, '<': 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': '3017157', 'n_tokens_mistral': 938, 'n_tokens_neox': 924, 'n_words': 254}