Skip to content

Commit

Permalink
Merge pull request #9889 from alphagov/content-modelling/871-internal…
Browse files Browse the repository at this point in the history
…-note-tweaks

(871) Internal note tweaks
  • Loading branch information
pezholio authored Feb 4, 2025
2 parents 5dc1afa + 25d1765 commit 24630ef
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def items
*details_items,
organisation_item,
instructions_item,
internal_change_note_item,
*change_note_items,
status_item,
].compact
Expand Down Expand Up @@ -57,6 +56,12 @@ def instructions_item
}
end

def change_note_items
return [] if content_block_edition.document.is_new_block?

content_block_edition.major_change ? [internal_change_note_item, major_change_item, external_change_note_item] : [internal_change_note_item, major_change_item]
end

def internal_change_note_item
{
field: "Internal note",
Expand All @@ -68,10 +73,6 @@ def internal_change_note_item
}
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?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def update
end

def context
"Edit content block"
@content_block_edition.document.is_new_block? ? "Create content block" : "Edit content block"
end
helper_method :context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<%= render "govuk_publishing_components/components/radio", {
name: "content_block/edition[major_change]",
hint: "Some content types show public change notes. GOV.UK users can subscribe to email alerts and RSS feeds and receive public change notes. Telling users when published information has changed is important for transparency.",
hint: "Some content types show public change notes. GOV.UK users can subscribe to email alerts and RSS feeds to receive public change notes. Telling users when published information has changed is important for transparency.",
id: "content_block_manager_content_block_edition_major_change",
error_items: errors_for(@content_block_edition.errors, :major_change),
items: [
Expand All @@ -31,12 +31,13 @@
conditional: render("govuk_publishing_components/components/textarea", {
label: {
text: "Describe the edit for users",
bold: true,
},
name: "content_block/edition[change_note]",
id: "content_block_manager_content_block_edition_change_note",
error_items: errors_for(@content_block_edition.errors, :change_note),
value: @content_block_edition.change_note,
hint: "Tell users what has been edited, where and why. Write in full sentences, leading with the most important words. For example, \"The full basic State Pension rate has changed from £85 per week to £93.60 per week.\"",
hint: "Tell users what has been edited, where and why. Write in full sentences, leading with the most important words. For example, \"The full basic State Pension rate has changed from £156.20 per week to £169.50 per week.\"",
}),
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% content_for :context, "Create a content block" %>
<% content_for :context, context %>
<% content_for :title, "Review #{@content_block_edition.block_type.humanize.downcase}" %>

<% content_for :back_link do %>
Expand Down Expand Up @@ -40,7 +40,7 @@
error: @confirm_error_copy,
items: [
{
label: "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct.",
label: "By #{@content_block_edition.document.is_new_block? ? "creating" : "editing"} this content block you are confirming that, to the best of your knowledge, the details you are providing are correct.",
value: true,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
end

Then("I confirm my answers are correct") do
check "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct."
check "is_confirmed"
end

Then("I accept and publish") do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ def add_change_note
end

def review_and_confirm
check "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct."
check "is_confirmed"
click_on @is_scheduled ? "Schedule" : "Publish"
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponen
organisation = create(:organisation, name: "Department for Example")

content_block_document = create(:content_block_document, :email_address)
content_block_document.stubs(:is_new_block?).returns(false)

content_block_edition = create(
:content_block_edition,
Expand Down Expand Up @@ -59,53 +60,88 @@ class ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponen
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)}']"
end

describe "when the change is major" do
it "shows the public change note" do
describe "when creating a new content block" do
let(:document) { create(:content_block_document, :email_address) }

before do
document.stubs(:is_new_block?).returns(true)
end

it "does not show change note information" do
content_block_edition = create(
:content_block_edition,
:email_address,
instructions_to_publishers: "some instructions",
major_change: true,
change_note: "Some change note",
document:,
)

render_inline(ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponent.new(
content_block_edition:,
))

assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__value", text: "Yes"
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: :change_note)}']"

assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__key", text: "Public change note"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__value", text: "Some change note"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__actions", text: "Edit"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__actions a[href='#{content_block_manager_content_block_workflow_path(id: content_block_edition.id, step: :change_note)}']"
assert_no_text "Internal note"
assert_no_text "Do users have to know the content has changed?"
assert_no_text "Public change note"
end
end

describe "when the change is not major" do
it "shows the public change note" do
content_block_edition = create(
:content_block_edition,
:email_address,
instructions_to_publishers: "some instructions",
major_change: false,
change_note: "Some change note",
)
describe "when editing an existing content block" do
let(:document) { create(:content_block_document, :email_address) }

render_inline(ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponent.new(
content_block_edition:,
))
before do
document.stubs(:is_new_block?).returns(false)
end

assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__value", text: "No"
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: :change_note)}']"
describe "when the change is major" do
it "shows the public change note" do
content_block_edition = create(
:content_block_edition,
:email_address,
instructions_to_publishers: "some instructions",
major_change: true,
change_note: "Some change note",
document:,
)

render_inline(ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponent.new(
content_block_edition:,
))

assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__value", text: "Yes"
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: :change_note)}']"

assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__key", text: "Public change note"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__value", text: "Some change note"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__actions", text: "Edit"
assert_selector ".govuk-summary-list__row:nth-child(7) .govuk-summary-list__actions a[href='#{content_block_manager_content_block_workflow_path(id: content_block_edition.id, step: :change_note)}']"
end
end

refute_selector ".govuk-summary-list__key", text: "Public change note"
refute_selector ".govuk-summary-list__value", text: "Some change note"
describe "when the change is not major" do
it "shows the public change note" do
content_block_edition = create(
:content_block_edition,
:email_address,
instructions_to_publishers: "some instructions",
major_change: false,
change_note: "Some change note",
document:,
)

render_inline(ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponent.new(
content_block_edition:,
))

assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__key", text: "Do users have to know the content has changed?"
assert_selector ".govuk-summary-list__row:nth-child(6) .govuk-summary-list__value", text: "No"
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: :change_note)}']"

refute_selector ".govuk-summary-list__key", text: "Public change note"
refute_selector ".govuk-summary-list__value", text: "Some change note"
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class ContentBlockManager::ContentBlock::WorkflowTest < ActionDispatch::Integrat
end

describe "when creating a new content block" do
before do
ContentBlockManager::ContentBlock::Document.any_instance.stubs(:is_new_block?).returns(true)
end

describe "when reviewing the changes" do
let(:step) { :review }

Expand All @@ -39,6 +43,13 @@ class ContentBlockManager::ContentBlock::WorkflowTest < ActionDispatch::Integrat
assert_template "content_block_manager/content_block/editions/workflow/review"
assert_equal edition, assigns(:content_block_edition)
end

it "shows the correct context and confirmation text" do
visit content_block_manager.content_block_manager_content_block_workflow_path(id: edition.id, step:)

assert_text "Create content block"
assert_text "By creating this content block you are confirming that, to the best of your knowledge, the details you are providing are correct."
end
end

describe "#update" do
Expand All @@ -64,6 +75,10 @@ class ContentBlockManager::ContentBlock::WorkflowTest < ActionDispatch::Integrat
end

describe "when updating an existing content block" do
before do
ContentBlockManager::ContentBlock::Document.any_instance.stubs(:is_new_block?).returns(false)
end

describe "when editing an existing edition" do
let(:step) { :edit_draft }

Expand Down Expand Up @@ -293,6 +308,17 @@ class ContentBlockManager::ContentBlock::WorkflowTest < ActionDispatch::Integrat
end
end
end

describe "when on the review step" do
let(:step) { :review }

it "shows the correct context and confirmation text" do
visit content_block_manager.content_block_manager_content_block_workflow_path(id: edition.id, step:)

assert_text "Edit content block"
assert_text "By editing this content block you are confirming that, to the best of your knowledge, the details you are providing are correct."
end
end
end

describe "when an unknown step is provided" do
Expand Down

0 comments on commit 24630ef

Please sign in to comment.