Skip to content

Commit

Permalink
Merge pull request #9882 from alphagov/content-modelling/874-change-u…
Browse files Browse the repository at this point in the history
…niverse-tweaks

(874) Change universe tweaks
  • Loading branch information
pezholio authored Feb 3, 2025
2 parents 3988aef + 8338381 commit 0e81126
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def items
organisation_item,
instructions_item,
status_item,
internal_change_note_item,
*change_note_items,
embed_code_item,
].compact
end
Expand Down Expand Up @@ -88,31 +86,6 @@ def status_item
end
end

def internal_change_note_item
{
field: "Internal change note",
value: content_block_edition.internal_change_note.presence || "None",
}
end

def change_note_items
content_block_edition.major_change ? [major_change_item, external_change_note_item] : [major_change_item]
end

def major_change_item
{
field: "Do users have to know the content has changed?",
value: content_block_edition.major_change ? "Yes" : "No",
}
end

def external_change_note_item
{
field: "Public change note",
value: content_block_edition.change_note,
}
end

def last_updated_value
"Published #{time_ago_in_words(content_block_edition.updated_at)} ago by #{content_block_edition.creator.name}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def instructions_item

def internal_change_note_item
{
field: "Internal change note",
field: "Internal note",
value: content_block_edition.internal_change_note.presence || "None",
edit: {
href: helpers.content_block_manager.content_block_manager_content_block_workflow_path(id: content_block_edition.id, step: :internal_note),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for :context, context %>
<% content_for :title, "Create internal change note" %>
<% content_for :title, "Create internal note" %>
<% content_for :title_margin_bottom, 4 %>
<% content_for :back_link do %>
<%= render "govuk_publishing_components/components/back_link", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes
scheduled_publication: Time.zone.now,
state: "published",
updated_at: 1.day.ago,
internal_change_note: "Some internal change note",
major_change: false,
)
end
let(:content_block_document) { content_block_edition.document }

it "renders a published content block correctly" do
render_inline(ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent.new(content_block_document:))

assert_selector ".govuk-summary-list__row", count: 10
assert_selector ".govuk-summary-list__row", count: 8
assert_selector ".govuk-summary-list__actions", count: 1

assert_selector ".govuk-summary-list__key", text: "Email address details"
Expand All @@ -45,15 +43,9 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes
assert_selector ".govuk-summary-list__key", text: "Status"
assert_selector ".govuk-summary-list__value", text: "Published 1 day ago by #{content_block_edition.creator.name}"

assert_selector ".govuk-summary-list__key", text: "Internal change note"
assert_selector ".govuk-summary-list__value", text: "Some internal change note"

assert_selector ".govuk-summary-list__key", text: "Instructions to publishers"
assert_selector ".govuk-summary-list__value", text: "None"

assert_selector ".govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__value", text: "No"

assert_selector ".govuk-summary-list__row[data-module='copy-embed-code']", text: "Embed code"
assert_selector ".govuk-summary-list__row[data-embed-code='#{content_block_document.embed_code}']", text: "Embed code"
assert_selector ".govuk-summary-list__key", text: "Embed code"
Expand All @@ -65,7 +57,7 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes

render_inline(ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent.new(content_block_document:))

assert_selector ".govuk-summary-list__row", count: 10
assert_selector ".govuk-summary-list__row", count: 8

assert_selector ".govuk-summary-list__key", text: "Status"
assert_selector ".govuk-summary-list__value", text: "Scheduled for publication at #{I18n.l(content_block_edition.scheduled_publication, format: :long_ordinal)}"
Expand All @@ -83,21 +75,4 @@ class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponentTes
assert_selector ".govuk-summary-list__value", text: "instructions"
end
end

describe "when there is a major change" do
it "renders the change note" do
content_block_document.latest_edition.major_change = true
content_block_document.latest_edition.change_note = "change note"

render_inline(ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent.new(content_block_document:))

assert_selector ".govuk-summary-list__row", count: 11

assert_selector ".govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__value", text: "Yes"

assert_selector ".govuk-summary-list__key", text: "Public change note"
assert_selector ".govuk-summary-list__value", text: "change note"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponen
assert_selector ".govuk-summary-list__row:nth-child(5) .govuk-summary-list__key", text: "Instructions to publishers"
assert_selector ".govuk-summary-list__row:nth-child(5) .govuk-summary-list__value", text: "None"

assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Internal change note"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Internal note"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__value", text: "Some internal info"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__actions", text: "Edit"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__actions a[href='#{content_block_manager_content_block_workflow_path(id: content_block_edition.id, step: :internal_note)}']"
Expand Down

0 comments on commit 0e81126

Please sign in to comment.