-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code to delete pages to pages controller
Refactor the forms delete confirmation controller to deal with forms only, and move the code for deleting pages to the pages controller; it is more idiomatic Rails to have the destroy and delete actions for a model in the controller for that model.
- Loading branch information
Showing
7 changed files
with
140 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% set_page_title(title_with_error_prefix(@confirm_deletion_legend, @delete_confirmation_input.errors.any?)) %> | ||
<% content_for :back_link, govuk_back_link_to(@back_url) %> | ||
|
||
<%= render( | ||
@delete_confirmation_input, | ||
url: @url, | ||
caption_text: @item_name, | ||
legend_text: @confirm_deletion_legend, | ||
hint_text: nil, | ||
) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "pages/delete" do | ||
before do | ||
assign(:back_url, edit_question_path(form_id: 1, page_id: 1)) | ||
assign(:confirm_deletion_legend, "Are you sure you want to delete this page?") | ||
assign(:delete_confirmation_input, Forms::DeleteConfirmationInput.new) | ||
assign(:item_name, "What’s your name?") | ||
assign(:url, destroy_page_path(form_id: 1, page_id: 1)) | ||
|
||
render | ||
end | ||
|
||
it "has a page title" do | ||
expect(view.content_for(:title)).to include "Are you sure you want to delete this page?" | ||
end | ||
|
||
it "has a heading" do | ||
expect(rendered).to have_css "h1", text: "Are you sure you want to delete this page?" | ||
end | ||
|
||
it "has a heading caption with the question text" do | ||
expect(rendered).to have_css ".govuk-caption-l", text: "What’s your name?" | ||
end | ||
|
||
it "has a back link to the edit question page" do | ||
expect(view.content_for(:back_link)).to have_link "Back", href: "/forms/1/pages/1/edit/question" | ||
end | ||
|
||
it "has a delete confirmation input to confirm deletion of the page" do | ||
expect(rendered).to render_template "input_objects/forms/_delete_confirmation_input" | ||
end | ||
|
||
describe "delete confirmation input" do | ||
it "posts to the destroy action" do | ||
expect(rendered).to have_element "form", action: "/forms/1/pages/1/delete", method: "post" | ||
end | ||
|
||
it "does not have a hint" do | ||
expect(rendered).not_to have_css ".govuk-hint" | ||
end | ||
end | ||
end |