Skip to content

Commit

Permalink
Merge pull request #9753 from alphagov/delete-review-dates
Browse files Browse the repository at this point in the history
Delete review dates
  • Loading branch information
ryanb-gds authored Dec 19, 2024
2 parents 2a27299 + 690cfb3 commit bf69868
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def add_review_reminder_action
href:,
secondary_quiet: true,
})
if Flipflop.delete_review_reminders? && review_reminder.present?
actions << link_to("Delete review date", confirm_destroy_admin_document_review_reminder_path(@edition.document, @edition.document.review_reminder), class: "govuk-link gem-link--destructive govuk-link--no-visited-state")
end
end
end

Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/review_reminders/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
text: "Save",
} %>

<% if Flipflop.delete_review_reminders? && review_reminder.persisted? %>
<%= link_to("Delete", confirm_destroy_admin_document_review_reminder_path(document, review_reminder), class: "govuk-link gem-link--destructive govuk-link--no-visited-state") %>
<% end %>
<%= link_to("Cancel", admin_edition_path(@document.latest_edition), class: "govuk-link govuk-link--no-visited-state") %>
</div>
<% end %>
3 changes: 2 additions & 1 deletion app/views/admin/review_reminders/confirm_destroy.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<div class="govuk-grid-row">
<section class="govuk-grid-column-two-thirds">
<p class="govuk-body"><span class="govuk-!-font-weight-bold">Review date:</span> <%= @review_reminder.review_at.strftime("%-d %B %Y") %></p>
<%= form_tag admin_document_review_reminder_path(@document, @review_reminder), method: :delete do %>
<p class="govuk-body govuk-!-margin-bottom-7">Are you sure you want to delete this review reminder?</p>

Expand All @@ -14,7 +15,7 @@
destructive: true,
} %>

<%= link_to("Cancel", edit_admin_document_review_reminder_path(@document, @review_reminder), class: "govuk-link govuk-link--no-visited-state") %>
<%= link_to("Cancel", admin_edition_path(@document.latest_edition), class: "govuk-link govuk-link--no-visited-state") %>
</div>
<% end %>
</section>
Expand Down
5 changes: 3 additions & 2 deletions features/review_reminder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Feature: Review reminders
Given a published publication "Standard Beard Lengths" with a PDF attachment
And The delete review reminder feature flag is "enabled"
And a review reminder exists for "Standard Beard Lengths" with the date "2032-1-1"
When I click the button "Edit review date" on the edition summary page for "Standard Beard Lengths"
And I delete the review date
When I click the link "Delete review date" on the edition summary page for "Standard Beard Lengths"
Then I should see the review date of "1 January 2032" on the deletion confirmation page
When I delete the review date
Then I should not see a review date on the edition summary page
11 changes: 10 additions & 1 deletion features/step_definitions/review_reminder_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__value", text: date
end

Then(/^I should see the review date of "([^"]*)" on the deletion confirmation page$/) do |date|
assert_selector ".govuk-body", text: "Review date: #{date}"
end

Then(/^I should not see a review date on the edition summary page$/) do
assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__key", text: "Review date"
assert_selector ".app-view-summary__section .govuk-summary-list__row:nth-child(5) .govuk-summary-list__value", text: "Not set"
Expand All @@ -35,6 +39,12 @@
click_on label
end

When(/^I click the link "([^"]*)" on the edition summary page for "([^"]*)"$/) do |label, title|
edition = Edition.find_by!(title:)
visit admin_edition_path(edition)
click_link label
end

And(/^a review reminder exists for "([^"]*)" with the date "([^"]*)"$/) do |title, date|
edition = Edition.find_by!(title:)
create(:review_reminder, document: edition.document, review_at: date)
Expand All @@ -57,6 +67,5 @@
end

And(/^I delete the review date$/) do
click_link "Delete"
click_button "Delete"
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ class Admin::Editions::Show::SidebarActionsComponentTest < ViewComponent::TestCa
assert_selector "a[href='https://www.test.gov.uk/government/generic-editions/#{edition.title}']", text: "View on website (opens in new tab)"
end

test "actions for published edition with review date" do
@test_strategy ||= Flipflop::FeatureSet.current.test!
@test_strategy.switch!(:delete_review_reminders, true)
current_user = build_stubbed(:user)
edition = create(:published_edition)
create(:review_reminder, :reminder_due, document: edition.document)
render_inline(Admin::Editions::Show::SidebarActionsComponent.new(edition:, current_user:))

assert_selector "li", count: 5
assert_selector "button", text: "Create new edition"
assert_selector "a", text: "Edit review date"
assert_selector "a", text: "Delete review date"
assert_selector "a", text: "View data about page"
assert_selector "a[href='https://www.test.gov.uk/government/generic-editions/#{edition.title}']", text: "View on website (opens in new tab)"
@test_strategy.switch!(:delete_review_reminders, false)
end

test "actions for published edition for non-english document" do
current_user = build_stubbed(:user)
edition = create(:non_english_published_edition)
Expand Down

0 comments on commit bf69868

Please sign in to comment.