Skip to content

Commit

Permalink
Add 'Cancel' to edit popular links
Browse files Browse the repository at this point in the history
  • Loading branch information
Ana Botto committed Jun 24, 2024
1 parent 3497b7a commit 135ab41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/views/homepage/popular_links/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
<% content_for :title, 'Edit popular links' %>
<% content_for :title_context, 'Popular on GOV.UK' %>
<% unless @latest_popular_links.errors.empty? %>
<% content_for :error_summary, render("shared/error_summary", { object: @latest_popular_links }) %>
<% content_for :error_summary, render("shared/error_summary", { object: @latest_popular_links }) %>
<% end %>

<div class="govuk-grid-column-two-thirds">
<%= form_for @latest_popular_links, url: update_popular_links_path(@latest_popular_links), method: "patch" do |form| %>
<% @latest_popular_links.link_items.each_with_index do |item, index| %>
<%= render "homepage/popular_links/form", item:, index:, form: %>
<% end %>
<%= render("govuk_publishing_components/components/button", {
text: "Save",
type: "submit",
}) %>
<div class="govuk-button-group">
<%= render("govuk_publishing_components/components/button", {
text: "Save",
type: "submit",
}) %>
<%= link_to("Cancel", show_popular_links_path, class: "govuk-link govuk-link--no-visited-state") %>
</div>
<% end %>
</div>
6 changes: 6 additions & 0 deletions test/integration/homepage_popular_links_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class HomepagePopularLinksTest < JavascriptIntegrationTest
assert page.has_text?("Title is required for Link 1")
assert page.has_text?("URL is required for Link 1")
end

should "render create page when clicked on 'cancel'" do
click_link("Cancel")

assert_current_path show_popular_links_path
end
end

context "#publish" do
Expand Down

0 comments on commit 135ab41

Please sign in to comment.