Browse Source
* CLDC-3614: Allow markdown page content when creating notifications * Try using beginning of day for time in failing test * Remove ignored breaks * Add paper trail to notifications * CLDC-3607: Allow support users to delete notifications (by setting their end date) (#2630) * CLDC-3607: Allow support users to delete notifications (by setting their end date) * Refactor render_for_page helper * Move db queries to homepage presenter * Fix lint * Use a before_action to find notification in controller * Make delete notification links red * Tweak link to markdown guidepull/2613/head
19 changed files with 315 additions and 55 deletions
@ -0,0 +1,17 @@
|
||||
<div class="govuk-grid-row"> |
||||
<p class="govuk-!-font-weight-bold"><%== I18n.t("active_notifications", count: active_notifications.count) %></p> |
||||
<% active_notifications.each do |notification| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-three-quarters"> |
||||
<%== render_for_home(notification) %> |
||||
</div> |
||||
<div class="govuk-grid-column-one-quarter"> |
||||
<%= govuk_link_to("Delete notification", notification_delete_confirmation_path(notification), class: "app-!-colour-red") %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<%= govuk_button_link_to "Create a new notification", new_notification_path %> |
||||
</div> |
||||
@ -0,0 +1,27 @@
|
||||
<% content_for :before_content do %> |
||||
<% content_for :title, "Are you sure you want to delete this notification?" %> |
||||
<%= govuk_back_link(href: :back) %> |
||||
<% end %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds-from-desktop"> |
||||
<h1 class="govuk-heading-xl"> |
||||
<%= content_for(:title) %> |
||||
</h1> |
||||
|
||||
<p class="govuk-body"><%== render_for_summary("**Notification:** #{@notification.title}") %></p> |
||||
|
||||
<p class="govuk-body">Users will no longer see this notification.</p> |
||||
|
||||
<%= govuk_warning_text(text: "You will not be able to undo this action.") %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= govuk_button_to( |
||||
"Delete notification", |
||||
notification_delete_path(@notification), |
||||
method: :delete, |
||||
) %> |
||||
<%= govuk_button_link_to "Cancel", root_path, html: { method: :get }, secondary: true %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,5 @@
|
||||
class AddShowAdditionalPageColumnToNotifications < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :notifications, :show_additional_page, :boolean |
||||
end |
||||
end |
||||
@ -0,0 +1,37 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Notification, type: :model do |
||||
describe "#valid?" do |
||||
context "when show additional page is true" do |
||||
context "and page_content is blank" do |
||||
let(:notification) { build(:notification, show_additional_page: true, page_content: "") } |
||||
|
||||
it "adds an error to page_content" do |
||||
notification.valid? |
||||
|
||||
expect(notification.errors[:page_content]).to include("Enter the page content") |
||||
end |
||||
end |
||||
|
||||
context "and link_text is blank" do |
||||
let(:notification) { build(:notification, show_additional_page: true, link_text: nil) } |
||||
|
||||
it "adds an error to link_text" do |
||||
notification.valid? |
||||
|
||||
expect(notification.errors[:link_text]).to include("Enter the link text") |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "when show additional page is false" do |
||||
context "and page_content and link_text are blank" do |
||||
let(:notification) { build(:notification, show_additional_page: false, link_text: nil, page_content: nil) } |
||||
|
||||
it "is valid" do |
||||
expect(notification).to be_valid |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue