From 9188b5c760931544897da44ca3ba7b8ffce6f019 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 26 Mar 2021 14:25:09 +0100 Subject: [PATCH] Do not expect an element to be persisted when building a content Rails don't need a content, and neiter do we. --- app/models/alchemy/content/factory.rb | 2 +- spec/models/alchemy/essence_richtext_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/alchemy/content/factory.rb b/app/models/alchemy/content/factory.rb index 8cf8288ea8..4c1f7ff253 100644 --- a/app/models/alchemy/content/factory.rb +++ b/app/models/alchemy/content/factory.rb @@ -26,7 +26,7 @@ def new(attributes = {}) super( name: definition[:name], essence_type: normalize_essence_type(definition[:type]), - element_id: element.id + element: element ).tap(&:build_essence) end diff --git a/spec/models/alchemy/essence_richtext_spec.rb b/spec/models/alchemy/essence_richtext_spec.rb index 1a070d67ec..57dc105b1c 100644 --- a/spec/models/alchemy/essence_richtext_spec.rb +++ b/spec/models/alchemy/essence_richtext_spec.rb @@ -4,7 +4,7 @@ module Alchemy describe EssenceRichtext do - let(:element) { create(:alchemy_element, name: "article") } + let(:element) { Alchemy::Element.new(name: "article") } let(:content) { Alchemy::Content.new(name: "text", element: element) } let(:essence) do Alchemy::EssenceRichtext.new( @@ -29,7 +29,7 @@ module Alchemy end context "when class is not part of the allowed attributes" do - let(:element) { create(:alchemy_element, name: "text") } + let(:element) { Alchemy::Element.new(name: "text") } let(:content) { Alchemy::Content.new(name: "text", element: element) } it "should save a sanitized version of body column" do