From 1d1d89ae53f7fb9c72d93d53dfdded7824a4a4a1 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 2 Mar 2021 17:31:19 +0100 Subject: [PATCH] Remove parent relations form element serializer We do not need parent relations like the page and the parent element in element serializer because usually you render top to bottom. --- app/serializers/alchemy/json_api/element_serializer.rb | 3 --- spec/serializers/alchemy/json_api/element_serializer_spec.rb | 2 -- 2 files changed, 5 deletions(-) diff --git a/app/serializers/alchemy/json_api/element_serializer.rb b/app/serializers/alchemy/json_api/element_serializer.rb index a2a3168..b996d73 100644 --- a/app/serializers/alchemy/json_api/element_serializer.rb +++ b/app/serializers/alchemy/json_api/element_serializer.rb @@ -16,9 +16,6 @@ class ElementSerializer !!element.definition[:deprecated] end - belongs_to :parent_element, record_type: :element, serializer: self - belongs_to :page, through: :page_version, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer - has_many :essences, polymorphic: true do |element| element.contents.map(&:essence) end diff --git a/spec/serializers/alchemy/json_api/element_serializer_spec.rb b/spec/serializers/alchemy/json_api/element_serializer_spec.rb index edde5bd..3772c20 100644 --- a/spec/serializers/alchemy/json_api/element_serializer_spec.rb +++ b/spec/serializers/alchemy/json_api/element_serializer_spec.rb @@ -45,10 +45,8 @@ subject { serializer.serializable_hash[:data][:relationships] } it "has the right keys and values" do - expect(subject[:page]).to eq(data: { id: element.page_id.to_s, type: :page }) expect(subject[:essences]).to eq(data: element.contents.map { |c| { id: c.essence_id.to_s, type: c.essence.class.name.demodulize.underscore.to_sym } }) expect(subject[:nested_elements]).to eq(data: [{ id: nested_element.id.to_s, type: :element }]) - expect(subject[:parent_element]).to eq(data: { id: parent_element.id.to_s, type: :element }) end end end