Browse Source

Remove submit lettings log button (#494)

pull/496/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
0d262bab51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/form_controller.rb
  2. 5
      app/models/form.rb
  3. 8
      app/views/form/page.html.erb
  4. 11
      spec/features/form/validations_spec.rb

2
app/controllers/form_controller.rb

@ -11,8 +11,6 @@ class FormController < ApplicationController
session[:errors] = nil
if is_referrer_check_answers? && !@case_log.form.next_page(@page, @case_log).to_s.include?("value_check")
redirect_to(send("case_log_#{@case_log.form.subsection_for_page(@page).id}_check_answers_path", @case_log))
elsif @case_log.form.is_last_question?(@page, @case_log.form.subsection_for_page(@page), @case_log)
redirect_to(case_logs_path)
else
redirect_path = @case_log.form.next_page_redirect_path(@page, @case_log)
redirect_to(send(redirect_path, @case_log))

5
app/models/form.rb

@ -140,11 +140,6 @@ class Form
questions.select { |q| q.type == "numeric" }
end
def is_last_question?(page, subsection, case_log)
subsection_ids = subsections.map(&:id)
subsection.id == subsection_ids[subsection_ids.length - 1] && next_page(page, case_log) == :check_answers
end
def previous_page(page_ids, page_index, case_log)
prev_page = get_page(page_ids[page_index - 1])
return prev_page.id if prev_page.routed_to?(case_log)

8
app/views/form/page.html.erb

@ -42,12 +42,8 @@
<% end %>
<%= f.hidden_field :page, value: @page.id %>
<% if @case_log.form.is_last_question?(@page, @subsection, @case_log) %>
<%= f.govuk_submit "Submit lettings log", accesskey: "s" %>
<% else %>
<% if !@page.id.include?("value_check") %>
<%= f.govuk_submit "Save and continue", accesskey: "s" %>
<% end %>
<% if !@page.id.include?("value_check") %>
<%= f.govuk_submit "Save and continue", accesskey: "s" %>
<% end %>
</div>
</div>

11
spec/features/form/validations_spec.rb

@ -154,18 +154,9 @@ RSpec.describe "validations" do
context "when tenant has not seen the privacy notice" do
it "shows a warning" do
visit("/logs/#{completed_without_declaration.id}/declaration")
click_button("Submit lettings log")
click_button("Save and continue")
expect(page).to have_content("You must show the DLUHC privacy notice to the tenant")
end
end
context "when tenant has seen the privacy notice" do
it "the log can be submitted" do
completed_without_declaration.update!({ declaration: 1 })
visit("/logs/#{completed_without_declaration.id}/declaration")
click_button("Submit lettings log")
expect(page).to have_current_path("/logs")
end
end
end
end

Loading…
Cancel
Save