From bc7497c9e1abf5495599959807cb36c46fcb87b6 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 22 Aug 2024 14:47:03 +0200 Subject: [PATCH] Remove EssenceSerializer mixin This is a left over. It is not included in any serializer anymore. --- lib/alchemy/json_api/essence_serializer.rb | 20 ---------- .../essence_serializer_behaviour.rb | 37 ------------------- spec/rails_helper.rb | 1 - 3 files changed, 58 deletions(-) delete mode 100644 lib/alchemy/json_api/essence_serializer.rb delete mode 100644 lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb diff --git a/lib/alchemy/json_api/essence_serializer.rb b/lib/alchemy/json_api/essence_serializer.rb deleted file mode 100644 index e3416b2..0000000 --- a/lib/alchemy/json_api/essence_serializer.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module Alchemy - module JsonApi - module EssenceSerializer - def self.included(klass) - klass.has_one :element, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |essence| - essence.content.element - end - klass.attributes :ingredient - klass.attribute :role do |essence| - essence.content.name - end - klass.attribute :deprecated do |essence| - !!essence.content.definition[:deprecated] - end - end - end - end -end diff --git a/lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb b/lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb deleted file mode 100644 index c446d8d..0000000 --- a/lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_examples "an essence serializer" do - describe "attributes" do - subject { serializer.serializable_hash[:data][:attributes] } - - it "has the right keys and values" do - expect(subject).to have_key(:ingredient) - expect(subject[:deprecated]).to be(false) - end - - context "a deprecated content" do - let(:content) { FactoryBot.create(:alchemy_content, name: "intro", element: element) } - - before do - expect(content).to receive(:definition).at_least(:once) do - { - name: "intro", - deprecated: true - } - end - end - - it "has deprecated attribute set to true" do - expect(subject[:deprecated]).to eq(true) - end - end - end - - describe "relationships" do - subject { serializer.serializable_hash[:data][:relationships] } - - it "has the right keys and values" do - expect(subject[:element]).to eq(data: {id: essence.element.id.to_s, type: :element}) - end - end -end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 82d7d7f..af57489 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -12,7 +12,6 @@ require "jsonapi/rspec" require "shoulda-matchers" -require "alchemy/json_api/test_support/essence_serializer_behaviour" require "alchemy/json_api/test_support/ingredient_serializer_behaviour" Shoulda::Matchers.configure do |config|