Browse Source

Implement current_lettings_form, current_sales_form and store year and form type in form

pull/875/head
Kat 3 years ago
parent
commit
c7dc3b339b
  1. 27
      app/models/form_handler.rb
  2. 2
      app/models/lettings_log.rb
  3. 2
      app/models/rent_period.rb
  4. 2
      app/models/sales_log.rb
  5. 8
      app/models/validations/date_validations.rb
  6. 2
      app/services/csv/lettings_log_csv_service.rb
  7. 8
      config/routes.rb
  8. 1
      spec/features/form/check_answers_page_spec.rb
  9. 1
      spec/features/form/conditional_questions_spec.rb
  10. 1
      spec/features/form/form_navigation_spec.rb
  11. 1
      spec/features/form/validations_spec.rb
  12. 4
      spec/helpers/conditional_questions_helper_spec.rb
  13. 4
      spec/helpers/question_attribute_helper_spec.rb
  14. 4
      spec/helpers/tasklist_helper_spec.rb
  15. 4
      spec/jobs/email_csv_job_spec.rb
  16. 4
      spec/models/form/page_spec.rb
  17. 4
      spec/models/form/question_spec.rb
  18. 4
      spec/models/form/section_spec.rb
  19. 1
      spec/models/form/subsection_spec.rb
  20. 29
      spec/models/form_handler_spec.rb
  21. 4
      spec/models/lettings_log_spec.rb
  22. 2
      spec/models/rent_period_spec.rb
  23. 4
      spec/models/validations/financial_validations_spec.rb
  24. 4
      spec/models/validations/household_validations_spec.rb
  25. 4
      spec/models/validations/shared_validations_spec.rb
  26. 4
      spec/requests/form_controller_spec.rb
  27. 1
      spec/requests/lettings_logs_controller_spec.rb

27
app/models/form_handler.rb

@ -7,19 +7,24 @@ class FormHandler
end end
def get_form(form) def get_form(form)
@forms[form] @forms[form].present? ? @forms[form]["form"] : nil
end end
def current_form def current_lettings_form
forms[forms.keys.max_by(&:to_i)] forms["current_lettings"]["form"]
end
def current_sales_form
forms["current_sales"]["form"]
end end
def sales_forms def sales_forms
sales_sections = [] # Add section classes here e.g. Form::Sales::Property::Sections::PropertyInformation sales_sections = [] # Add section classes here e.g. Form::Sales::Property::Sections::PropertyInformation
{ "2022_2023_sales" => Form.new(nil, "2022_2023_sales", sales_sections, "sales"), current_form = Form.new(nil, "#{current_collection_start_year}_#{current_collection_start_year + 1}_sales", sales_sections, "sales")
"current_sales" => Form.new(nil, "#{current_collection_start_year}_#{current_collection_start_year + 1}_sales", sales_sections, "sales"), previous_form = Form.new(nil, "#{current_collection_start_year - 1}_#{current_collection_start_year}_sales", sales_sections, "sales")
"previous_sales" => Form.new(nil, "#{current_collection_start_year - 1}_#{current_collection_start_year}_sales", sales_sections, "sales"), { "2022_2023_sales" => { "form" => Form.new(nil, "2022_2023_sales", sales_sections, "sales"), "type" => "sales" },
"next_sales" => Form.new(nil, "#{current_collection_start_year + 1}_#{current_collection_start_year + 2}_sales", sales_sections, "sales") } "current_sales" => { "form" => current_form, "type" => "sales", "start_year" => current_form.start_date.year },
"previous_sales" => { "form" => previous_form, "type" => "sales", "start_year" => previous_form.start_date.year } }
end end
def lettings_forms def lettings_forms
@ -28,13 +33,13 @@ class FormHandler
Dir.glob("#{directory}/*.json").each do |form_path| Dir.glob("#{directory}/*.json").each do |form_path|
form_name = File.basename(form_path, ".json") form_name = File.basename(form_path, ".json")
form = Form.new(form_path, form_name) form = Form.new(form_path, form_name)
forms[form_name] = form forms[form_name] = { "form" => form, "type" => "lettings", "start_year" => form.start_date.year }
if form.start_date.year + 1 == current_collection_start_year && forms["previous_lettings"].blank? if form.start_date.year + 1 == current_collection_start_year && forms["previous_lettings"].blank?
forms["previous_lettings"] = form forms["previous_lettings"] = { "form" => form, "type" => "lettings", "start_year" => form.start_date.year }
elsif form.start_date.year == current_collection_start_year && forms["current_lettings"].blank? elsif form.start_date.year == current_collection_start_year && forms["current_lettings"].blank?
forms["current_lettings"] = form forms["current_lettings"] = { "form" => form, "type" => "lettings", "start_year" => form.start_date.year }
elsif form.start_date.year - 1 == current_collection_start_year && forms["next_lettings"].blank? elsif form.start_date.year - 1 == current_collection_start_year && forms["next_lettings"].blank?
forms["next_lettings"] = form forms["next_lettings"] = { "form" => form, "type" => "lettings", "start_year" => form.start_date.year }
end end
end end
end end

2
app/models/lettings_log.rb

@ -55,7 +55,7 @@ class LettingsLog < Log
RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze
def form def form
FormHandler.instance.get_form(form_name) || FormHandler.instance.forms.first.second FormHandler.instance.get_form(form_name) || FormHandler.instance.current_lettings_form
end end
def recalculate_start_year! def recalculate_start_year!

2
app/models/rent_period.rb

@ -1,5 +1,5 @@
class RentPeriod class RentPeriod
def self.rent_period_mappings def self.rent_period_mappings
FormHandler.instance.current_form.get_question("period", nil).answer_options FormHandler.instance.current_lettings_form.get_question("period", nil).answer_options
end end
end end

2
app/models/sales_log.rb

@ -27,7 +27,7 @@ class SalesLog < Log
end end
def form def form
FormHandler.instance.get_form(form_name) || FormHandler.instance.get_form("2022_2023_sales") FormHandler.instance.get_form(form_name) || FormHandler.instance.current_sales_form
end end
def optional_fields def optional_fields

8
app/models/validations/date_validations.rb

@ -60,19 +60,19 @@ module Validations::DateValidations
private private
def first_collection_start_date def first_collection_start_date
@first_collection_start_date ||= FormHandler.instance.forms.map { |form| form.second.start_date }.compact.min @first_collection_start_date ||= FormHandler.instance.forms.map { |_name, form| form["form"].start_date }.compact.min
end end
def first_collection_end_date def first_collection_end_date
@first_collection_end_date ||= FormHandler.instance.forms.map { |form| form.second.end_date }.compact.min @first_collection_end_date ||= FormHandler.instance.forms.map { |_name, form| form["form"].end_date }.compact.min
end end
def second_collection_start_date def second_collection_start_date
@second_collection_start_date ||= FormHandler.instance.forms.map { |form| form.second.start_date }.compact.max @second_collection_start_date ||= FormHandler.instance.forms.map { |_name, form| form["form"].start_date }.compact.max
end end
def second_collection_end_date def second_collection_end_date
@second_collection_end_date ||= FormHandler.instance.forms.map { |form| form.second.end_date }.compact.max @second_collection_end_date ||= FormHandler.instance.forms.map { |_name, form| form["form"].end_date }.compact.max
end end
def date_valid?(question, record) def date_valid?(question, record)

2
app/services/csv/lettings_log_csv_service.rb

@ -51,7 +51,7 @@ module Csv
def ordered_form_questions def ordered_form_questions
downloaded_form_years = LettingsLog.all.map(&:collection_start_year).uniq.compact downloaded_form_years = LettingsLog.all.map(&:collection_start_year).uniq.compact
downloaded_form_fields = downloaded_form_years.count == 1 && downloaded_form_years[0].present? ? FormHandler.instance.get_form("#{downloaded_form_years[0]}_#{downloaded_form_years[0] + 1}").questions : FormHandler.instance.forms.first.second.questions downloaded_form_fields = downloaded_form_years.count == 1 && downloaded_form_years[0].present? ? FormHandler.instance.get_form("#{downloaded_form_years[0]}_#{downloaded_form_years[0] + 1}").questions : FormHandler.instance.current_lettings_form.questions
move_checkbox_answer_options(downloaded_form_fields) move_checkbox_answer_options(downloaded_form_fields)
end end

8
config/routes.rb

@ -93,11 +93,11 @@ Rails.application.routes.draw do
end end
FormHandler.instance.lettings_forms.each do |_key, form| FormHandler.instance.lettings_forms.each do |_key, form|
form.pages.map do |page| form["form"].pages.map do |page|
get page.id.to_s.dasherize, to: "form#show_page" get page.id.to_s.dasherize, to: "form#show_page"
end end
form.subsections.map do |subsection| form["form"].subsections.map do |subsection|
get "#{subsection.id.to_s.dasherize}/check-answers", to: "form#check_answers" get "#{subsection.id.to_s.dasherize}/check-answers", to: "form#check_answers"
end end
end end
@ -105,11 +105,11 @@ Rails.application.routes.draw do
resources :sales_logs, path: "/sales-logs" do resources :sales_logs, path: "/sales-logs" do
FormHandler.instance.sales_forms.each do |_key, form| FormHandler.instance.sales_forms.each do |_key, form|
form.pages.map do |page| form["form"].pages.map do |page|
get page.id.to_s.dasherize, to: "form#show_page" get page.id.to_s.dasherize, to: "form#show_page"
end end
form.subsections.map do |subsection| form["form"].subsections.map do |subsection|
get "#{subsection.id.to_s.dasherize}/check-answers", to: "form#check_answers" get "#{subsection.id.to_s.dasherize}/check-answers", to: "form#check_answers"
end end
end end

1
spec/features/form/check_answers_page_spec.rb

@ -42,6 +42,7 @@ RSpec.describe "Form Check Answers Page" do
before do before do
sign_in user sign_in user
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
context "when the user needs to check their answers for a subsection" do context "when the user needs to check their answers for a subsection" do

1
spec/features/form/conditional_questions_spec.rb

@ -16,6 +16,7 @@ RSpec.describe "Form Conditional Questions" do
before do before do
sign_in user sign_in user
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
context "with a page where some questions are only conditionally shown, depending on how you answer the first question" do context "with a page where some questions are only conditionally shown, depending on how you answer the first question" do

1
spec/features/form/form_navigation_spec.rb

@ -35,6 +35,7 @@ RSpec.describe "Form Navigation" do
before do before do
sign_in user sign_in user
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
describe "Create a new lettings log" do describe "Create a new lettings log" do

1
spec/features/form/validations_spec.rb

@ -4,6 +4,7 @@ require_relative "helpers"
RSpec.describe "validations" do RSpec.describe "validations" do
before do before do
sign_in user sign_in user
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
include Helpers include Helpers

4
spec/helpers/conditional_questions_helper_spec.rb

@ -4,6 +4,10 @@ RSpec.describe ConditionalQuestionsHelper do
let(:lettings_log) { FactoryBot.build(:lettings_log) } let(:lettings_log) { FactoryBot.build(:lettings_log) }
let(:page) { lettings_log.form.get_page("armed_forces") } let(:page) { lettings_log.form.get_page("armed_forces") }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
describe "conditional questions for page" do describe "conditional questions for page" do
let(:conditional_pages) { %w[leftreg] } let(:conditional_pages) { %w[leftreg] }

4
spec/helpers/question_attribute_helper_spec.rb

@ -5,6 +5,10 @@ RSpec.describe QuestionAttributeHelper do
let(:form) { lettings_log.form } let(:form) { lettings_log.form }
let(:questions) { form.get_page("rent").questions } let(:questions) { form.get_page("rent").questions }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
describe "html attributes" do describe "html attributes" do
it "returns empty hash if fields-to-add or result-field are empty " do it "returns empty hash if fields-to-add or result-field are empty " do
question = form.get_page("weekly_net_income").questions.find { |q| q.id == "earnings" } question = form.get_page("weekly_net_income").questions.find { |q| q.id == "earnings" }

4
spec/helpers/tasklist_helper_spec.rb

@ -4,6 +4,10 @@ RSpec.describe TasklistHelper do
let(:empty_lettings_log) { FactoryBot.create(:lettings_log) } let(:empty_lettings_log) { FactoryBot.create(:lettings_log) }
let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, needstype: 1) } let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, needstype: 1) }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
describe "get next incomplete section" do describe "get next incomplete section" do
it "returns the first subsection name if it is not completed" do it "returns the first subsection name if it is not completed" do
expect(get_next_incomplete_section(lettings_log).id).to eq("household_characteristics") expect(get_next_incomplete_section(lettings_log).id).to eq("household_characteristics")

4
spec/jobs/email_csv_job_spec.rb

@ -10,6 +10,10 @@ describe EmailCsvJob do
let(:organisation) { user.organisation } let(:organisation) { user.organisation }
let(:other_organisation) { FactoryBot.create(:organisation) } let(:other_organisation) { FactoryBot.create(:organisation) }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
context "when a log exists" do context "when a log exists" do
let!(:lettings_log) do let!(:lettings_log) do
FactoryBot.create( FactoryBot.create(

4
spec/models/form/page_spec.rb

@ -15,6 +15,10 @@ RSpec.describe Form::Page, type: :model do
let(:page_id) { "net_income" } let(:page_id) { "net_income" }
let(:page_definition) { subsection_definition["pages"][page_id] } let(:page_definition) { subsection_definition["pages"][page_id] }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
it "has an id" do it "has an id" do
expect(page.id).to eq(page_id) expect(page.id).to eq(page_id)
end end

4
spec/models/form/question_spec.rb

@ -17,6 +17,10 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "earnings" } let(:question_id) { "earnings" }
let(:question_definition) { page_definition["questions"][question_id] } let(:question_definition) { page_definition["questions"][question_id] }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
it "has an id" do it "has an id" do
expect(question.id).to eq(question_id) expect(question.id).to eq(question_id)
end end

4
spec/models/form/section_spec.rb

@ -8,6 +8,10 @@ RSpec.describe Form::Section, type: :model do
let(:section_id) { "household" } let(:section_id) { "household" }
let(:section_definition) { form.form_definition["sections"][section_id] } let(:section_definition) { form.form_definition["sections"][section_id] }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
it "has an id" do it "has an id" do
expect(section.id).to eq(section_id) expect(section.id).to eq(section_id)
end end

1
spec/models/form/subsection_spec.rb

@ -14,6 +14,7 @@ RSpec.describe Form::Subsection, type: :model do
before do before do
RequestHelper.stub_http_requests RequestHelper.stub_http_requests
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
it "has an id" do it "has an id" do

29
spec/models/form_handler_spec.rb

@ -2,6 +2,7 @@ require "rails_helper"
RSpec.describe FormHandler do RSpec.describe FormHandler do
let(:test_form_name) { "2021_2022" } let(:test_form_name) { "2021_2022" }
let(:form_handler) { described_class.instance }
before { Singleton.__init__(described_class) } before { Singleton.__init__(described_class) }
@ -15,14 +16,12 @@ RSpec.describe FormHandler do
end end
it "is able to load a current lettings form" do it "is able to load a current lettings form" do
form_handler = described_class.instance
form = form_handler.get_form("current_lettings") form = form_handler.get_form("current_lettings")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(45) expect(form.pages.count).to eq(45)
end end
it "is able to load a next lettings form" do it "is able to load a next lettings form" do
form_handler = described_class.instance
form = form_handler.get_form("next_lettings") form = form_handler.get_form("next_lettings")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(12) expect(form.pages.count).to eq(12)
@ -31,37 +30,32 @@ RSpec.describe FormHandler do
describe "Get all forms" do describe "Get all forms" do
it "is able to load all the forms" do it "is able to load all the forms" do
form_handler = described_class.instance
all_forms = form_handler.forms all_forms = form_handler.forms
expect(all_forms.count).to be >= 1 expect(all_forms.count).to be >= 1
expect(all_forms[test_form_name]).to be_a(Form) expect(all_forms[test_form_name]["form"]).to be_a(Form)
end end
end end
describe "Get specific form" do describe "Get specific form" do
it "is able to load a specific form" do it "is able to load a specific form" do
form_handler = described_class.instance
form = form_handler.get_form(test_form_name) form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(45) expect(form.pages.count).to eq(45)
end end
it "is able to load a current lettings form" do it "is able to load a current lettings form" do
form_handler = described_class.instance
form = form_handler.get_form("current_lettings") form = form_handler.get_form("current_lettings")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(12) expect(form.pages.count).to eq(12)
end end
it "is able to load a previous lettings form" do it "is able to load a previous lettings form" do
form_handler = described_class.instance
form = form_handler.get_form("previous_lettings") form = form_handler.get_form("previous_lettings")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(45) expect(form.pages.count).to eq(45)
end end
it "is able to load a current sales form" do it "is able to load a current sales form" do
form_handler = described_class.instance
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(1) expect(form.pages.count).to eq(1)
@ -69,26 +63,16 @@ RSpec.describe FormHandler do
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form_handler = described_class.instance
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(1) expect(form.pages.count).to eq(1)
expect(form.name).to eq("2021_2022_sales") expect(form.name).to eq("2021_2022_sales")
end end
it "is able to load a next sales form" do
form_handler = described_class.instance
form = form_handler.get_form("next_sales")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(1)
expect(form.name).to eq("2023_2024_sales")
end
end end
describe "Current form" do describe "Current form" do
it "returns the latest form by date" do it "returns the latest form by date" do
form_handler = described_class.instance form = form_handler.current_lettings_form
form = form_handler.current_form
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.start_date.year).to eq(2022) expect(form.start_date.year).to eq(2022)
end end
@ -101,7 +85,12 @@ RSpec.describe FormHandler do
end end
it "can get a saleslog form" do it "can get a saleslog form" do
form_handler = described_class.instance
expect(form_handler.get_form("2022_2023_sales")).to be_a(Form) expect(form_handler.get_form("2022_2023_sales")).to be_a(Form)
end end
it "keeps track of form type and start year" do
form = form_handler.forms["current_lettings"]
expect(form["type"]).to eq("lettings")
expect(form["start_year"]).to eq(2022)
end
end end

4
spec/models/lettings_log_spec.rb

@ -5,6 +5,10 @@ RSpec.describe LettingsLog do
let(:different_managing_organisation) { FactoryBot.create(:organisation) } let(:different_managing_organisation) { FactoryBot.create(:organisation) }
let(:created_by_user) { FactoryBot.create(:user) } let(:created_by_user) { FactoryBot.create(:user) }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
it "inherits from log" do it "inherits from log" do
expect(described_class).to be < Log expect(described_class).to be < Log
expect(described_class).to be < ApplicationRecord expect(described_class).to be < ApplicationRecord

2
spec/models/rent_period_spec.rb

@ -5,7 +5,7 @@ RSpec.describe RentPeriod, type: :model do
let(:form) { Form.new("spec/fixtures/forms/2021_2022.json", "2021_2022") } let(:form) { Form.new("spec/fixtures/forms/2021_2022.json", "2021_2022") }
before do before do
allow(FormHandler.instance).to receive(:current_form).and_return(form) allow(FormHandler.instance).to receive(:current_lettings_form).and_return(form)
end end
it "maps rent period id to display names" do it "maps rent period id to display names" do

4
spec/models/validations/financial_validations_spec.rb

@ -6,6 +6,10 @@ RSpec.describe Validations::FinancialValidations do
let(:validator_class) { Class.new { include Validations::FinancialValidations } } let(:validator_class) { Class.new { include Validations::FinancialValidations } }
let(:record) { FactoryBot.create(:lettings_log) } let(:record) { FactoryBot.create(:lettings_log) }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
describe "earnings and income frequency" do describe "earnings and income frequency" do
it "when earnings are provided it validates that income frequency must be provided" do it "when earnings are provided it validates that income frequency must be provided" do
record.earnings = 500 record.earnings = 500

4
spec/models/validations/household_validations_spec.rb

@ -6,6 +6,10 @@ RSpec.describe Validations::HouseholdValidations do
let(:validator_class) { Class.new { include Validations::HouseholdValidations } } let(:validator_class) { Class.new { include Validations::HouseholdValidations } }
let(:record) { FactoryBot.create(:lettings_log) } let(:record) { FactoryBot.create(:lettings_log) }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
describe "reasonable preference validations" do describe "reasonable preference validations" do
context "when reasonable preference is homeless" do context "when reasonable preference is homeless" do
context "when the tenant was not previously homeless" do context "when the tenant was not previously homeless" do

4
spec/models/validations/shared_validations_spec.rb

@ -7,6 +7,10 @@ RSpec.describe Validations::SharedValidations do
let(:record) { FactoryBot.create(:lettings_log) } let(:record) { FactoryBot.create(:lettings_log) }
describe "numeric min max validations" do describe "numeric min max validations" do
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
context "when validating age" do context "when validating age" do
it "validates that person 1's age is a number" do it "validates that person 1's age is a number" do
record.age1 = "random" record.age1 = "random"

4
spec/requests/form_controller_spec.rb

@ -39,6 +39,10 @@ RSpec.describe FormController, type: :request do
end end
let(:headers) { { "Accept" => "text/html" } } let(:headers) { { "Accept" => "text/html" } }
before do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end
context "when a user is not signed in" do context "when a user is not signed in" do
describe "GET" do describe "GET" do
it "does not let you get lettings logs pages you don't have access to" do it "does not let you get lettings logs pages you don't have access to" do

1
spec/requests/lettings_logs_controller_spec.rb

@ -23,6 +23,7 @@ RSpec.describe LettingsLogsController, type: :request do
allow(ENV).to receive(:[]) allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("API_USER").and_return(api_username) allow(ENV).to receive(:[]).with("API_USER").and_return(api_username)
allow(ENV).to receive(:[]).with("API_KEY").and_return(api_password) allow(ENV).to receive(:[]).with("API_KEY").and_return(api_password)
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(FormHandler.instance.forms["2021_2022"]["form"])
end end
describe "POST #create" do describe "POST #create" do

Loading…
Cancel
Save