Skip to content

Commit

Permalink
Remove template local from skip_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasiles committed Dec 12, 2024
1 parent d1bfc73 commit 3b94350
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
19 changes: 9 additions & 10 deletions app/controllers/pages/secondary_skip_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@ class Pages::SecondarySkipController < PagesController
before_action :ensure_secondary_skip_exists, only: %i[edit update delete destroy]

def new
secondary_skip_input = Pages::SecondarySkipInput.new(form: current_form, page:)
render locals: { secondary_skip_input: }
@secondary_skip_input = Pages::SecondarySkipInput.new(form: current_form, page:)
end

def create
secondary_skip_input = Pages::SecondarySkipInput.new(secondary_skip_input_params)
@secondary_skip_input = Pages::SecondarySkipInput.new(secondary_skip_input_params)

if secondary_skip_input.submit
if @secondary_skip_input.submit
redirect_to show_routes_path(form_id: current_form.id, page_id: page.id)
else
render template: "pages/secondary_skip/new", locals: { secondary_skip_input: }, status: :unprocessable_entity
render template: "pages/secondary_skip/new", status: :unprocessable_entity
end
end

def edit
secondary_skip_input = Pages::SecondarySkipInput.new(form: current_form, page:, record: secondary_skip_condition).assign_values
@secondary_skip_input = Pages::SecondarySkipInput.new(form: current_form, page:, record: secondary_skip_condition).assign_values

render template: "pages/secondary_skip/edit", locals: { secondary_skip_input: }
render template: "pages/secondary_skip/edit"
end

def update
secondary_skip_input = Pages::SecondarySkipInput.new(secondary_skip_input_params.merge(record: secondary_skip_condition))
@secondary_skip_input = Pages::SecondarySkipInput.new(secondary_skip_input_params.merge(record: secondary_skip_condition))

if secondary_skip_input.submit
if @secondary_skip_input.submit
redirect_to show_routes_path(form_id: current_form.id, page_id: page.id)
else
render template: "pages/secondary_skip/edit", locals: { secondary_skip_input: }, status: :unprocessable_entity
render template: "pages/secondary_skip/edit", status: :unprocessable_entity
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/views/pages/secondary_skip/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% set_page_title(title_with_error_prefix(t('page_titles.new_secondary_skip', route_index: 2), false)) %>
<% content_for :back_link, govuk_back_link_to(show_routes_path(form_id: secondary_skip_input.form.id, page_id: secondary_skip_input.page.id), t('secondary_skip.new.back', page_position: secondary_skip_input.page.position)) %>
<% content_for :back_link, govuk_back_link_to(show_routes_path(form_id: @secondary_skip_input.form.id, page_id: @secondary_skip_input.page.id), t('secondary_skip.new.back', page_position: @secondary_skip_input.page.position)) %>

<% content_for :heading do %>
<h1 class="govuk-heading-l">
<span class="govuk-caption-l"><%= t("secondary_skip.new.caption", page_position: secondary_skip_input.page.position) %></span>
<span class="govuk-caption-l"><%= t("secondary_skip.new.caption", page_position: @secondary_skip_input.page.position) %></span>
<%= t("page_titles.new_secondary_skip", route_index: 2) %>
<%# TODO: route_index is hardcoded as 2 here because we know there are only two conditions. It will need to change in the future %>
</h1>
Expand All @@ -12,8 +12,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: 'form', locals: {
secondary_skip_input:,
submit_path: update_secondary_skip_path(form_id: secondary_skip_input.form.id, page_id: secondary_skip_input.page.id),
secondary_skip_input: @secondary_skip_input,
submit_path: update_secondary_skip_path(form_id: @secondary_skip_input.form.id, page_id: @secondary_skip_input.page.id),
} %>
</div>
</div>
8 changes: 4 additions & 4 deletions app/views/pages/secondary_skip/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% set_page_title(title_with_error_prefix(t('page_titles.new_secondary_skip', route_index: 2), false)) %>
<% content_for :back_link, govuk_back_link_to(show_routes_path(form_id: secondary_skip_input.form.id, page_id: secondary_skip_input.page.id), t('secondary_skip.new.back', page_position: secondary_skip_input.page.position)) %>
<% content_for :back_link, govuk_back_link_to(show_routes_path(form_id: @secondary_skip_input.form.id, page_id: @secondary_skip_input.page.id), t('secondary_skip.new.back', page_position: @secondary_skip_input.page.position)) %>

<% content_for :heading do %>
<h1 class="govuk-heading-l">
<span class="govuk-caption-l"><%= t("secondary_skip.new.caption", page_position: secondary_skip_input.page.position) %></span>
<span class="govuk-caption-l"><%= t("secondary_skip.new.caption", page_position: @secondary_skip_input.page.position) %></span>
<%= t("page_titles.new_secondary_skip", route_index: 2) %>
<%# TODO: route_index is hardcoded as 2 here because we know there are only two conditions. It will need to change in the future %>
</h1>
Expand All @@ -12,8 +12,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: 'form', locals: {
secondary_skip_input:,
submit_path: create_secondary_skip_path(form_id: secondary_skip_input.form.id, page_id: secondary_skip_input.page.id),
secondary_skip_input: @secondary_skip_input,
submit_path: create_secondary_skip_path(form_id: @secondary_skip_input.form.id, page_id: @secondary_skip_input.page.id),
} %>
</div>
</div>
3 changes: 2 additions & 1 deletion spec/views/pages/secondary_skip/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
let(:secondary_skip_input) { Pages::SecondarySkipInput.new(form:, page:) }

before do
render template: "pages/secondary_skip/new", locals: { secondary_skip_input: }
assign(:secondary_skip_input, secondary_skip_input)
render template: "pages/secondary_skip/new"
end

it "has the correct title" do
Expand Down

0 comments on commit 3b94350

Please sign in to comment.