Browse Source

Folder structure (#901)

* Update the folder structure

* Add specs

* testy 💁‍♀️

* Update names in tests 🫠
pull/903/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
fb9e1c50e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/form/sales/pages/property_number_of_bedrooms.rb
  2. 10
      app/models/form/sales/property/sections/property_information.rb
  3. 2
      app/models/form/sales/questions/property_number_of_bedrooms.rb
  4. 10
      app/models/form/sales/sections/property_information.rb
  5. 4
      app/models/form/sales/subsections/property_information.rb
  6. 2
      app/models/form_handler.rb
  7. 2
      spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb
  8. 2
      spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb
  9. 29
      spec/models/form/sales/sections/household_spec.rb
  10. 29
      spec/models/form/sales/sections/property_information_spec.rb
  11. 27
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  12. 27
      spec/models/form/sales/subsections/property_information_spec.rb
  13. 4
      spec/models/form_spec.rb

4
app/models/form/sales/property/pages/property_number_of_bedrooms.rb → app/models/form/sales/pages/property_number_of_bedrooms.rb

@ -1,4 +1,4 @@
class Form::Sales::Property::Pages::PropertyNumberOfBedrooms < ::Form::Page class Form::Sales::Pages::PropertyNumberOfBedrooms < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "property_number_of_bedrooms" @id = "property_number_of_bedrooms"
@ -9,7 +9,7 @@ class Form::Sales::Property::Pages::PropertyNumberOfBedrooms < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Property::Questions::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Questions::PropertyNumberOfBedrooms.new(nil, nil, self),
] ]
end end
end end

10
app/models/form/sales/property/sections/property_information.rb

@ -1,10 +0,0 @@
class Form::Sales::Property::Sections::PropertyInformation < ::Form::Section
def initialize(id, hsh, form)
super
@id = "property_information"
@label = "Property information"
@description = ""
@form = form
@subsections = [Form::Sales::Property::Subsections::PropertyInformation.new(nil, nil, self)] || []
end
end

2
app/models/form/sales/property/questions/property_number_of_bedrooms.rb → app/models/form/sales/questions/property_number_of_bedrooms.rb

@ -1,4 +1,4 @@
class Form::Sales::Property::Questions::PropertyNumberOfBedrooms < ::Form::Question class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "beds" @id = "beds"

10
app/models/form/sales/sections/property_information.rb

@ -0,0 +1,10 @@
class Form::Sales::Sections::PropertyInformation < ::Form::Section
def initialize(id, hsh, form)
super
@id = "property_information"
@label = "Property information"
@description = ""
@form = form
@subsections = [Form::Sales::Subsections::PropertyInformation.new(nil, nil, self)] || []
end
end

4
app/models/form/sales/property/subsections/property_information.rb → app/models/form/sales/subsections/property_information.rb

@ -1,4 +1,4 @@
class Form::Sales::Property::Subsections::PropertyInformation < ::Form::Subsection class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
def initialize(id, hsh, section) def initialize(id, hsh, section)
super super
@id = "property_information" @id = "property_information"
@ -9,7 +9,7 @@ class Form::Sales::Property::Subsections::PropertyInformation < ::Form::Subsecti
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Property::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
] ]
end end
end end

2
app/models/form_handler.rb

@ -20,7 +20,7 @@ class FormHandler
def sales_forms def sales_forms
sales_sections = [ sales_sections = [
Form::Sales::Property::Sections::PropertyInformation, Form::Sales::Sections::PropertyInformation,
Form::Sales::Sections::Household, Form::Sales::Sections::Household,
] ]
current_form = Form.new(nil, current_collection_start_year, sales_sections, "sales") current_form = Form.new(nil, current_collection_start_year, sales_sections, "sales")

2
spec/models/form/sales/property/pages/property_number_of_bedrooms_spec.rb → spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Property::Pages::PropertyNumberOfBedrooms, type: :model do RSpec.describe Form::Sales::Pages::PropertyNumberOfBedrooms, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil } let(:page_id) { nil }

2
spec/models/form/sales/property/questions/property_number_of_bedrooms_spec.rb → spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Property::Questions::PropertyNumberOfBedrooms, type: :model do RSpec.describe Form::Sales::Questions::PropertyNumberOfBedrooms, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }

29
spec/models/form/sales/sections/household_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Sections::Household, type: :model do
subject(:household) { described_class.new(section_id, section_definition, form) }
let(:section_id) { nil }
let(:section_definition) { nil }
let(:form) { instance_double(Form) }
it "has correct form" do
expect(household.form).to eq(form)
end
it "has correct subsections" do
expect(household.subsections.map(&:id)).to eq(%w[household_characteristics])
end
it "has the correct id" do
expect(household.id).to eq("household")
end
it "has the correct label" do
expect(household.label).to eq("About the household")
end
it "has the correct description" do
expect(household.description).to eq("")
end
end

29
spec/models/form/sales/sections/property_information_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Sections::PropertyInformation, type: :model do
subject(:property_information) { described_class.new(section_id, section_definition, form) }
let(:section_id) { nil }
let(:section_definition) { nil }
let(:form) { instance_double(Form) }
it "has correct form" do
expect(property_information.form).to eq(form)
end
it "has correct subsections" do
expect(property_information.subsections.map(&:id)).to eq(%w[property_information])
end
it "has the correct id" do
expect(property_information.id).to eq("property_information")
end
it "has the correct label" do
expect(property_information.label).to eq("Property information")
end
it "has the correct description" do
expect(property_information.description).to eq("")
end
end

27
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -0,0 +1,27 @@
require "rails_helper"
RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model do
subject(:household_characteristics) { described_class.new(subsection_id, subsection_definition, section) }
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::Household) }
it "has correct section" do
expect(household_characteristics.section).to eq(section)
end
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
%w[buyer_1_age],
)
end
it "has the correct id" do
expect(household_characteristics.id).to eq("household_characteristics")
end
it "has the correct label" do
expect(household_characteristics.label).to eq("Household characteristics")
end
end

27
spec/models/form/sales/subsections/property_information_spec.rb

@ -0,0 +1,27 @@
require "rails_helper"
RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
subject(:property_information) { described_class.new(subsection_id, subsection_definition, section) }
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::PropertyInformation) }
it "has correct section" do
expect(property_information.section).to eq(section)
end
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
%w[property_number_of_bedrooms],
)
end
it "has the correct id" do
expect(property_information.id).to eq("property_information")
end
it "has the correct label" do
expect(property_information.label).to eq("Property information")
end
end

4
spec/models/form_spec.rb

@ -227,12 +227,12 @@ RSpec.describe Form, type: :model do
end end
it "can correctly define sections in the sales form" do it "can correctly define sections in the sales form" do
sections = [Form::Sales::Property::Sections::PropertyInformation] sections = [Form::Sales::Sections::PropertyInformation]
form = described_class.new(nil, 2022, sections, "sales") form = described_class.new(nil, 2022, sections, "sales")
expect(form.type).to eq("sales") expect(form.type).to eq("sales")
expect(form.name).to eq("2022_2023_sales") expect(form.name).to eq("2022_2023_sales")
expect(form.sections.count).to eq(2) expect(form.sections.count).to eq(2)
expect(form.sections[1].class).to eq(Form::Sales::Property::Sections::PropertyInformation) expect(form.sections[1].class).to eq(Form::Sales::Sections::PropertyInformation)
end end
end end
end end

Loading…
Cancel
Save