From 8364ba4c987e0bd7aca4862b4c381d2e042a9d97 Mon Sep 17 00:00:00 2001 From: JonathanHallam Date: Mon, 9 Dec 2024 14:09:08 +0000 Subject: [PATCH] Strip the "editionable" prefix when displaying document type names We're adding support for editionable topical events. This requires us to create a new content type that we've called "editionable_topical_events". When displaying the name we should strip the editionable bit so it looks nicer. --- app/helpers/admin/new_document_helper.rb | 2 +- app/models/editionable_topical_event.rb | 4 ++++ features/support/document_helper.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/admin/new_document_helper.rb b/app/helpers/admin/new_document_helper.rb index 29a46e3148b..453cca4a07c 100644 --- a/app/helpers/admin/new_document_helper.rb +++ b/app/helpers/admin/new_document_helper.rb @@ -20,7 +20,7 @@ def new_document_type_list .select { |edition_type| can?(:create, edition_type) } .map do |edition_type| title_value = edition_type.name.underscore - title_label = title_value.humanize + title_label = title_value.gsub("editionable_", "").humanize { value: title_value, text: title_label, diff --git a/app/models/editionable_topical_event.rb b/app/models/editionable_topical_event.rb index 55ca636c0fd..21f905102c4 100644 --- a/app/models/editionable_topical_event.rb +++ b/app/models/editionable_topical_event.rb @@ -2,4 +2,8 @@ class EditionableTopicalEvent < Edition def display_type_key "editionable_topical_event" end + + def self.format_name + "topical event" + end end diff --git a/features/support/document_helper.rb b/features/support/document_helper.rb index 4b0c8f39e0d..277812775e1 100644 --- a/features/support/document_helper.rb +++ b/features/support/document_helper.rb @@ -18,7 +18,7 @@ def begin_drafting_document(options) create(:organisation) if Organisation.count.zero? visit admin_root_path find("li.app-c-sub-navigation__list-item a", text: "New document").click - page.choose(options[:type].humanize) + page.choose(options[:type].gsub("editionable_", "").humanize) click_button("Next") if options[:locale]