From 4fa1eca70e84ca7157b0e5dcbb4cc60f9f10b25f Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 9 Nov 2023 18:31:41 -0500 Subject: [PATCH] fix update page with raw_schema field --- lib/beacon/content/page.ex | 1 + test/beacon/content_test.exs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/beacon/content/page.ex b/lib/beacon/content/page.ex index 0288ca91..9ec8f7b6 100644 --- a/lib/beacon/content/page.ex +++ b/lib/beacon/content/page.ex @@ -112,6 +112,7 @@ defmodule Beacon.Content.Page do :title, :description, :meta_tags, + :raw_schema, :format ]) |> cast(attrs, [:path], empty_values: []) diff --git a/test/beacon/content_test.exs b/test/beacon/content_test.exs index 79c06ae5..30feb83a 100644 --- a/test/beacon/content_test.exs +++ b/test/beacon/content_test.exs @@ -276,6 +276,21 @@ defmodule Beacon.ContentTest do }) end + test "update raw_schema" do + layout = layout_fixture(site: :raw_schema_test) + + page = + Content.create_page!(%{ + site: "my_site", + path: "/", + template: "

page

", + layout_id: layout.id, + raw_schema: [%{"foo" => "bar"}] + }) + + assert {:ok, %Page{raw_schema: [%{"@type" => "BlogPosting"}]}} = Content.update_page(page, %{"raw_schema" => [%{"@type" => "BlogPosting"}]}) + end + test "validate raw_schema" do layout = layout_fixture(site: :raw_schema_test)