Browse Source

Add test for looping sections back, add migration

pull/279/head
Kat 3 years ago
parent
commit
1bf1951b56
  1. 2
      app/models/form.rb
  2. 15
      db/migrate/20220208101235_remove_gdpr_fields.rb
  3. 2
      spec/features/form/check_answers_page_spec.rb
  4. 6
      spec/models/form_spec.rb

2
app/models/form.rb

@ -79,7 +79,7 @@ class Form
next_subsection_id_index = subsection_ids.index(subsection.id) + 1 next_subsection_id_index = subsection_ids.index(subsection.id) + 1
next_subsection = get_subsection(subsection_ids[next_subsection_id_index]) next_subsection = get_subsection(subsection_ids[next_subsection_id_index])
if next_subsection.id == "declaration" && case_log.status != "completed" if subsection.id == "declaration" && case_log.status != "completed"
next_subsection = get_subsection(subsection_ids[0]) next_subsection = get_subsection(subsection_ids[0])
end end

15
db/migrate/20220208101235_remove_gdpr_fields.rb

@ -0,0 +1,15 @@
class RemoveGdprFields < ActiveRecord::Migration[7.0]
def up
change_table :case_logs, bulk: true do |t|
t.remove :gdpr_declined
t.remove :gdpr_acceptance
end
end
def down
change_table :case_logs, bulk: true do |t|
t.column :gdpr_declined, :string
t.column :gdpr_acceptance, :string
end
end
end

2
spec/features/form/check_answers_page_spec.rb

@ -209,7 +209,7 @@ RSpec.describe "Form Check Answers Page" do
end end
it "they can click a button to cycle around to the next incomplete section" do it "they can click a button to cycle around to the next incomplete section" do
visit("/logs/#{cycle_sections_case_log.id}/local-authority/check-answers") visit("/logs/#{cycle_sections_case_log.id}/declaration/check-answers")
click_link("Save and go to next incomplete section") click_link("Save and go to next incomplete section")
expect(page).to have_current_path("/logs/#{cycle_sections_case_log.id}/tenant-code") expect(page).to have_current_path("/logs/#{cycle_sections_case_log.id}/tenant-code")
end end

6
spec/models/form_spec.rb

@ -36,7 +36,7 @@ RSpec.describe Form, type: :model do
describe "next_incomplete_section_redirect_path" do describe "next_incomplete_section_redirect_path" do
let(:case_log) { FactoryBot.build(:case_log, :in_progress) } let(:case_log) { FactoryBot.build(:case_log, :in_progress) }
let(:subsection) { form.get_subsection("household_characteristics") } let(:subsection) { form.get_subsection("household_characteristics") }
let(:later_subsection) { form.get_subsection("setup") } let(:later_subsection) { form.get_subsection("declaration") }
context "when a user is on the check answers page for a subsection" do context "when a user is on the check answers page for a subsection" do
def answer_household_needs(case_log) def answer_household_needs(case_log)
@ -111,6 +111,10 @@ RSpec.describe Form, type: :model do
expect(form.next_incomplete_section_redirect_path(subsection, completed_case_log)).to eq("declaration") expect(form.next_incomplete_section_redirect_path(subsection, completed_case_log)).to eq("declaration")
end end
it "returns the next incomplete section by cycling back around if next subsections are completed" do
expect(form.next_incomplete_section_redirect_path(later_subsection, case_log)).to eq("armed-forces")
end
it "returns the declaration section if all sections are complete but the case log is in progress" do it "returns the declaration section if all sections are complete but the case log is in progress" do
answer_household_needs(case_log) answer_household_needs(case_log)
answer_tenancy_information(case_log) answer_tenancy_information(case_log)

Loading…
Cancel
Save