From 19d8c345eab542a91cecbe521eda8a2b28894c13 Mon Sep 17 00:00:00 2001 From: pezholio Date: Wed, 4 Dec 2024 10:36:57 +0000 Subject: [PATCH] Change header when editing --- .../content_block/editions_controller.rb | 2 ++ .../content_block/editions/new.html.erb | 2 +- .../test/integration/content_block/editions_test.rb | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/editions_controller.rb b/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/editions_controller.rb index 516cf5d6ae1..70b88058c1f 100644 --- a/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/editions_controller.rb +++ b/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/editions_controller.rb @@ -1,10 +1,12 @@ class ContentBlockManager::ContentBlock::EditionsController < ContentBlockManager::BaseController def new if params[:document_id] + @title = "Edit a content block" @content_block_document = ContentBlockManager::ContentBlock::Document.find(params[:document_id]) @schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(@content_block_document.block_type) content_block_edition = @content_block_document.latest_edition else + @title = "Create a content block" @schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(params[:block_type].underscore) content_block_edition = ContentBlockManager::ContentBlock::Edition.new end diff --git a/lib/engines/content_block_manager/app/views/content_block_manager/content_block/editions/new.html.erb b/lib/engines/content_block_manager/app/views/content_block_manager/content_block/editions/new.html.erb index b520ed095bb..d24f46f79c4 100644 --- a/lib/engines/content_block_manager/app/views/content_block_manager/content_block/editions/new.html.erb +++ b/lib/engines/content_block_manager/app/views/content_block_manager/content_block/editions/new.html.erb @@ -1,4 +1,4 @@ -<% content_for :context, "Create a content block" %> +<% content_for :context, @title %> <% content_for :title, @form.title %> <% content_for :back_link do %> diff --git a/lib/engines/content_block_manager/test/integration/content_block/editions_test.rb b/lib/engines/content_block_manager/test/integration/content_block/editions_test.rb index f37681defad..53a5fe88f35 100644 --- a/lib/engines/content_block_manager/test/integration/content_block/editions_test.rb +++ b/lib/engines/content_block_manager/test/integration/content_block/editions_test.rb @@ -25,7 +25,9 @@ class ContentBlockManager::ContentBlock::EditionsTest < ActionDispatch::Integrat schema:, ).returns(form) - get content_block_manager.new_content_block_manager_content_block_document_edition_path(content_block_document) + visit content_block_manager.new_content_block_manager_content_block_document_edition_path(content_block_document) + + assert_text "Edit a content block" end end @@ -40,7 +42,9 @@ class ContentBlockManager::ContentBlock::EditionsTest < ActionDispatch::Integrat schema:, ).returns(form) - get content_block_manager.new_content_block_manager_content_block_edition_path(block_type: "block-type") + visit content_block_manager.new_content_block_manager_content_block_edition_path(block_type: "block-type") + + assert_text "Create a content block" end end end