Skip to content

Commit

Permalink
Link to block from Whitehall history
Browse files Browse the repository at this point in the history
This also tweaks the copy so users can see what has been
updated.
  • Loading branch information
pezholio committed Jan 13, 2025
1 parent 1ffff81 commit ef7e2df
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
margin-bottom: govuk-spacing(4);
}

&__detail {
&__detail,
&__link {
margin-top: govuk-spacing(0);
margin-bottom: govuk-spacing(0);
}

&__heading {
margin-bottom: govuk-spacing(1);
margin-bottom: govuk-spacing(0);
}

&__datetime {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<div class="app-view-editions-host-content-update-event-entry__list-item">
<h4 class="govuk-heading-s app-view-editions-host-content-update-event-entry__heading">Content Block Update</h4>
<h4 class="govuk-heading-s app-view-editions-host-content-update-event-entry__heading">Content block updated</h4>

<p class="govuk-body app-view-editions-host-content-update-event-entry__detail">
<%= activity %>
<p class="app-view-editions-host-content-update-event-entry__detail">
<%= block_type %>: <%= block_name %>
</p>

<p class="govuk-body app-view-editions-host-content-update-event-entry__link">
<%= link_to link_text, helpers.content_block_manager.content_block_manager_content_block_content_id_path(content_id: event.content_id), class: "govuk-link" %>
</p>

<p class="govuk-body-s app-view-editions-host-content-update-event-entry__datetime">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ def initialize(event)

attr_reader :event

def activity
"#{event.content_title.strip} updated"
def block_type
event.document_type
end

def block_name
event.content_title.strip
end

def link_text
"[View#{tag.span(" #{block_name}", class: 'govuk-visually-hidden')} in Content Block Manager]".html_safe
end

def time
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/content_block_update_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
selector = current_or_previous == "current" ? ".app-view-editions__current-edition-entries" : ".app-view-editions__previous-edition-entries"

within selector do
assert_text "Content Block Update"
assert_text "#{content_block} updated"
assert_text "Content block updated"
assert_text content_block
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

class Admin::Editions::HostContentUpdateEventComponentTest < ViewComponent::TestCase
extend Minitest::Spec::DSL
include Rails.application.routes.url_helpers
include ContentBlockManager::Engine.routes.url_helpers

let(:created_at) { Time.zone.local(2020, 1, 1, 11, 11) }
let(:content_title) { "Some content" }
let(:document_type) { "Email address" }
let(:user) { build_stubbed(:user) }

let(:host_content_update_event) do
build(:host_content_update_event, content_title:, created_at:, author: user)
build(:host_content_update_event, content_title:, created_at:, author: user, document_type:)
end

it "constructs output based on the entry when an actor is present" do
render_inline(Admin::Editions::HostContentUpdateEventComponent.new(host_content_update_event))

assert_equal page.find("h4").text, "Content Block Update"
assert_equal page.all("p")[0].text.strip, "#{content_title} updated"
assert_equal page.all("p")[1].text.strip, "1 January 2020 11:11am by #{user.name}"
assert_equal page.find("h4").text, "Content block updated"
assert_equal page.all("p")[0].text.strip, "#{document_type}: #{content_title}"
assert_equal page.all("a")[0].native.inner_html, "[View<span class=\"govuk-visually-hidden\"> #{content_title}</span> in Content Block Manager]"
assert_equal page.all("a")[0].native["href"], content_block_manager_content_block_content_id_path(content_id: host_content_update_event.content_id)

assert_equal page.all("p")[2].text.strip, "1 January 2020 11:11am by #{user.name}"
end

describe "when an actor is not present" do
Expand All @@ -26,7 +30,7 @@ class Admin::Editions::HostContentUpdateEventComponentTest < ViewComponent::Test
it "shows removed user when an actor is not present" do
render_inline(Admin::Editions::HostContentUpdateEventComponent.new(host_content_update_event))

assert_equal page.all("p")[1].text.strip, "1 January 2020 11:11am by User (removed)"
assert_equal page.all("p")[2].text.strip, "1 January 2020 11:11am by User (removed)"
end
end
end

0 comments on commit ef7e2df

Please sign in to comment.