Skip to content

Commit

Permalink
Merge pull request #9226 from alphagov/remove-generic-edition-presenter
Browse files Browse the repository at this point in the history
Remove `GenericEditionPresenter`
  • Loading branch information
pezholio authored Jul 4, 2024
2 parents 724c90a + 64b6d8d commit c8bf9bb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 134 deletions.
4 changes: 0 additions & 4 deletions app/models/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,6 @@ def force_scheduled?
force_published? && state == "scheduled"
end

def publishing_api_presenter
PublishingApi::GenericEditionPresenter
end

def can_have_custom_lead_image?
is_a?(Edition::CustomLeadImage)
end
Expand Down
37 changes: 0 additions & 37 deletions app/presenters/publishing_api/generic_edition_presenter.rb

This file was deleted.

7 changes: 7 additions & 0 deletions test/support/generic_edition.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
require_relative "./generic_edition_presenter"

class GenericEdition < Edition
include Attachable

class << self
attr_accessor :translatable
end

def translatable?
self.class.translatable
end

def publishing_api_presenter
GenericEditionPresenter
end
end
27 changes: 27 additions & 0 deletions test/support/generic_edition_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class GenericEditionPresenter
include Presenters::PublishingApi::UpdateTypeHelper

attr_accessor :item, :update_type

def initialize(item, update_type: nil)
self.item = item
self.update_type = update_type || default_update_type(item)
end

delegate :content_id, to: :item

def content
content = PublishingApi::BaseItemPresenter.new(item, update_type:).base_attributes
content.merge!(
description: item.summary,
)
end

def links
PublishingApi::PayloadBuilder::Links.for(item).extract([:organisations])
end

def document_type
item.display_type_key
end
end
2 changes: 1 addition & 1 deletion test/unit/app/models/edition/appointment_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "test_helper"

class Edition::AppointmentTest < ActiveSupport::TestCase
class EditionWithAppointment < Edition
class EditionWithAppointment < GenericEdition
include ::Edition::Searchable
include ::Edition::Appointment

Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions test/unit/app/presenters/publishing_api_presenters_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class PublishingApiPresentersTest < ActiveSupport::TestCase
PublishingApiPresenters.presenter_for(Speech.new).class
end

test ".presenter_for returns a Generic Edition presenter for all models without a presenter class" do
assert_equal PublishingApi::GenericEditionPresenter,
PublishingApiPresenters.presenter_for(GenericEdition.new).class
end

test ".presenter_for returns a Placeholder presenter for an organisation" do
organisation = Organisation.new
presenter = PublishingApiPresenters.presenter_for(organisation)
Expand Down

0 comments on commit c8bf9bb

Please sign in to comment.