Skip to content

Commit

Permalink
Remove parent relations form element serializer
Browse files Browse the repository at this point in the history
We do not need parent relations like the page and the parent element in
element serializer because usually you render top to bottom.
  • Loading branch information
tvdeyen committed Mar 2, 2021
1 parent 600b60c commit 1d1d89a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 5 deletions.
3 changes: 0 additions & 3 deletions app/serializers/alchemy/json_api/element_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/serializers/alchemy/json_api/element_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1d1d89a

Please sign in to comment.