Skip to content

Commit

Permalink
rename unprocessable entity to unprocessable content to match Rack
Browse files Browse the repository at this point in the history
  • Loading branch information
reedrolemodel committed Dec 17, 2024
1 parent 1007de9 commit b9508a0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/tests/fixtures/422.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<html>
<head>
<title>Unprocessable Entity</title>
<title>Unprocessable Content</title>
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
</head>
<body>
<h1>Unprocessable Entity</h1>
<h1>Unprocessable Content</h1>

<turbo-frame id="frame">
<h2>Frame: Unprocessable Entity</h2>
<h2>Frame: Unprocessable Content</h2>
</turbo-frame>
</body>
</html>
6 changes: 3 additions & 3 deletions src/tests/fixtures/422_morph.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<meta name="turbo-refresh-method" content="morph">
<meta name="turbo-refresh-scroll" content="preserve">

<title>Unprocessable Entity</title>
<title>Unprocessable Content</title>
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
</head>
<body>
<h1>Unprocessable Entity</h1>
<h1>Unprocessable Content</h1>

<turbo-frame id="frame">
<h2>Frame: Unprocessable Entity</h2>
<h2>Frame: Unprocessable Content</h2>
</turbo-frame>
</body>
</html>
6 changes: 3 additions & 3 deletions src/tests/fixtures/422_tall.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<html>
<head>
<title>Unprocessable Entity</title>
<title>Unprocessable Content</title>
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
</head>
<body>
<main style="height: 1000vh">
<h1>Unprocessable Entity</h1>
<h1>Unprocessable Content</h1>
<turbo-frame id="frame">
<h2>Frame: Unprocessable Entity</h2>
<h2>Frame: Unprocessable Content</h2>
</turbo-frame>
</main>
</body>
Expand Down
6 changes: 3 additions & 3 deletions src/tests/fixtures/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ <h1>Form</h1>
</div>
<hr>
<div id="reject">
<form class="unprocessable_entity" action="/__turbo/reject" method="post" style="margin-top:100vh">
<form class="unprocessable_content" action="/__turbo/reject" method="post" style="margin-top:100vh">
<input type="hidden" name="status" value="422">
<input type="submit">
</form>
<form class="unprocessable_entity_with_tall_form" action="/__turbo/reject/tall" method="post">
<form class="unprocessable_content_with_tall_form" action="/__turbo/reject/tall" method="post">
<input type="hidden" name="status" value="422">
<input type="submit" style="margin-top:1000vh">
</form>
Expand Down Expand Up @@ -263,7 +263,7 @@ <h2>Frame: Form</h2>
<input type="hidden" name="status" value="204">
<input type="submit" style="">
</form>
<form class="unprocessable_entity" action="/__turbo/reject" method="post">
<form class="unprocessable_content" action="/__turbo/reject" method="post">
<input type="hidden" name="status" value="422">
<input type="submit">
</form>
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/page_refresh.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h3>Element with Stimulus controller</h3>
<button id="add-new-assets">Add new assets</button>

<div id="reject">
<form class="unprocessable_entity" action="/__turbo/reject/morph" method="post" style="margin-top:100vh">
<form class="unprocessable_content" action="/__turbo/reject/morph" method="post" style="margin-top:100vh">
<input type="hidden" name="status" value="422">
<input type="submit">
</form>
Expand Down
18 changes: 9 additions & 9 deletions src/tests/functional/form_submission_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,22 +576,22 @@ test("input named action with action attribute", async ({ page }) => {
assert.equal(getSearchParam(page.url(), "query"), "1")
})

test("invalid form submission with unprocessable entity status", async ({ page }) => {
await page.click("#reject form.unprocessable_entity input[type=submit]")
test("invalid form submission with unprocessable content status", async ({ page }) => {
await page.click("#reject form.unprocessable_content input[type=submit]")
await nextBody(page)

const title = await page.locator("h1")
assert.equal(await title.textContent(), "Unprocessable Entity", "renders the response HTML")
assert.equal(await title.textContent(), "Unprocessable Content", "renders the response HTML")
assert.notOk(await hasSelector(page, "#frame form.reject"), "replaces entire page")
})

test("invalid form submission with long form", async ({ page }) => {
await scrollToSelector(page, "#reject form.unprocessable_entity_with_tall_form input[type=submit]")
await page.click("#reject form.unprocessable_entity_with_tall_form input[type=submit]")
await scrollToSelector(page, "#reject form.unprocessable_content_with_tall_form input[type=submit]")
await page.click("#reject form.unprocessable_content_with_tall_form input[type=submit]")
await nextBody(page)

const title = await page.locator("h1")
assert.equal(await title.textContent(), "Unprocessable Entity", "renders the response HTML")
assert.equal(await title.textContent(), "Unprocessable Content", "renders the response HTML")
assert(await isScrolledToTop(page), "page is scrolled to the top")
assert.notOk(await hasSelector(page, "#frame form.reject"), "replaces entire page")
})
Expand Down Expand Up @@ -891,8 +891,8 @@ test("frame form submission within a frame submits the Turbo-Frame header", asyn
assert.ok(fetchOptions.headers["Turbo-Frame"], "submits with the Turbo-Frame header")
})

test("invalid frame form submission with unprocessable entity status", async ({ page }) => {
await page.click("#frame form.unprocessable_entity input[type=submit]")
test("invalid frame form submission with unprocessable content status", async ({ page }) => {
await page.click("#frame form.unprocessable_content input[type=submit]")

assert.ok(await formSubmitStarted(page), "fires turbo:submit-start")
await nextEventNamed(page, "turbo:before-fetch-request")
Expand All @@ -906,7 +906,7 @@ test("invalid frame form submission with unprocessable entity status", async ({

const title = await page.locator("#frame h2")
assert.ok(await hasSelector(page, "#reject form"), "only replaces frame")
assert.equal(await title.textContent(), "Frame: Unprocessable Entity")
assert.equal(await title.textContent(), "Frame: Unprocessable Content")
})

test("invalid frame form submission with internal server error status", async ({ page }) => {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/functional/page_refresh_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ test("it preserves data-turbo-permanent elements that don't match when their ids
await expect(page.locator("#preserve-me")).toHaveText("Preserve me, I have a family!")
})

test("renders unprocessable entity responses with morphing", async ({ page }) => {
test("renders unprocessable content responses with morphing", async ({ page }) => {
await page.goto("/src/tests/fixtures/page_refresh.html")

await page.click("#reject form.unprocessable_entity input[type=submit]")
await page.click("#reject form.unprocessable_content input[type=submit]")
await nextEventNamed(page, "turbo:render", { renderMethod: "morph" })
await nextBody(page)

const title = await page.locator("h1")
assert.equal(await title.textContent(), "Unprocessable Entity", "renders the response HTML")
assert.equal(await title.textContent(), "Unprocessable Content", "renders the response HTML")
assert.notOk(await hasSelector(page, "#frame form.reject"), "replaces entire page")
})

Expand Down

0 comments on commit b9508a0

Please sign in to comment.