From 79a1812335fddebc3613f1db9a9a07cd86008410 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 16 Sep 2021 15:17:32 +0100 Subject: [PATCH] Commit tests --- spec/features/case_log_spec.rb | 9 +++++++++ spec/models/case_log_spec.rb | 4 ++++ spec/models/form_spec.rb | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 spec/models/case_log_spec.rb create mode 100644 spec/models/form_spec.rb diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 5d2c6e3ad..8e6e16e2b 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -28,6 +28,15 @@ RSpec.describe "Test Features" do expect(page).to have_field("tenant-age-field") click_button("Save and continue") expect(page).to have_field("tenant-gender-0-field") + visit page.driver.request.env['HTTP_REFERER'] + expect(page).to have_field("tenant-age-field") + end + + describe "form questions" do + it "can be accessed by url" do + visit("/case_logs/#{id}/tenant_age") + expect(page).to have_field("tenant-age-field") + end end end end diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb new file mode 100644 index 000000000..08b41d6c2 --- /dev/null +++ b/spec/models/case_log_spec.rb @@ -0,0 +1,4 @@ +require "rails_helper" + +RSpec.describe Form, type: :model do +end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb new file mode 100644 index 000000000..91125ecb3 --- /dev/null +++ b/spec/models/form_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.describe Form, type: :model do + describe ".next_question" do + let(:previous_question) { "tenant_age" } + it "returns the next question given the previous" do + expect(Form.next_question(previous_question)).to eq("tenant_gender") + end + end + + describe ".first_question_for_subsection" do + let(:subsection) { "household_characteristics" } + it "returns the next question given the previous" do + expect(Form.first_question_for_subsection(subsection)).to eq("tenant_code") + end + end +end