-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9791 from alphagov/content-modelling/177-edition-…
…title content-modelling/777 - remove title from Content Block Document and use the title on Content Block Editions
- Loading branch information
Showing
29 changed files
with
125 additions
and
202 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
db/migrate/20250106160308_change_title_to_sluggable_string_on_content_block_documents.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ChangeTitleToSluggableStringOnContentBlockDocuments < ActiveRecord::Migration[7.1] | ||
def up | ||
rename_column :content_block_documents, :title, :sluggable_string | ||
end | ||
|
||
def down | ||
rename_column :content_block_documents, :sluggable_string, :title | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,6 @@ | |
assert_not_nil edition | ||
assert_not_nil edition.document | ||
|
||
assert_equal @title, edition.document_title if @title.present? | ||
assert_equal @title, edition.title if @title.present? | ||
assert_equal @instructions_to_publishers, edition.instructions_to_publishers if @instructions_to_publishers.present? | ||
|
||
|
@@ -233,6 +232,7 @@ def has_support_button | |
details: { email_address: @email_address }, | ||
creator: @user, | ||
organisation:, | ||
title: "previously created title", | ||
) | ||
ContentBlockManager::ContentBlock::Edition::HasAuditTrail.acting_as(@user) do | ||
@content_block.publish! | ||
|
@@ -248,7 +248,7 @@ def has_support_button | |
instructions_to_publishers = fields.delete("instructions_to_publishers") | ||
|
||
(1..count.to_i).each do |_i| | ||
document = create(:content_block_document, block_type.to_sym, title:) | ||
document = create(:content_block_document, block_type.to_sym, sluggable_string: title.parameterize(separator: "_")) | ||
|
||
editions = create_list( | ||
:content_block_edition, | ||
|
@@ -259,6 +259,7 @@ def has_support_button | |
details: fields, | ||
creator: @user, | ||
instructions_to_publishers:, | ||
title:, | ||
) | ||
|
||
document.latest_edition = editions.last | ||
|
@@ -271,14 +272,16 @@ def has_support_button | |
@content_blocks ||= [] | ||
@email_address = "[email protected]" | ||
organisation = create(:organisation) | ||
document = create(:content_block_document, :email_address, title: fields[:title]) | ||
title = fields.delete("title") || "title" | ||
document = create(:content_block_document, :email_address, sluggable_string: title.parameterize(separator: "_")) | ||
@content_block = create( | ||
:content_block_edition, | ||
:email_address, | ||
document:, | ||
details: { email_address: fields[:email_address] }, | ||
creator: @user, | ||
organisation:, | ||
title:, | ||
) | ||
ContentBlockManager::ContentBlock::Edition::HasAuditTrail.acting_as(@user) do | ||
@content_block.publish! | ||
|
@@ -811,8 +814,8 @@ def click_save_and_continue | |
within(".govuk-summary-card", text: content_block_name) do | ||
find("a", text: "Copy code").click | ||
has_text?("Code copied") | ||
document = ContentBlockManager::ContentBlock::Document.find_by(title: content_block_name) | ||
@embed_code = document.embed_code | ||
edition = ContentBlockManager::ContentBlock::Edition.find_by(title: content_block_name) | ||
@embed_code = edition.document.embed_code | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/engines/content_block_manager/test/factories/content_block_document.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,12 @@ class ContentBlockManager::ContentBlock::DocumentsTest < ActionDispatch::Integra | |
details: { "email_address" => "[email protected]" }, | ||
document_id: document_with_latest_edition.id, | ||
) | ||
document_without_latest_edition = create(:content_block_document, :email_address, title: "no latest edition") | ||
_document_without_latest_edition = create(:content_block_document, :email_address, sluggable_string: "no latest edition") | ||
|
||
visit content_block_manager.content_block_manager_content_block_documents_path({ lead_organisation: "" }) | ||
|
||
assert_text document_with_latest_edition.latest_edition.details["email_address"] | ||
assert_no_text document_without_latest_edition.title | ||
assert_text "1 result" | ||
end | ||
|
||
describe "when no filter params are specified" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.