Browse Source

Merge branch 'main' into RemoveBuyerOrg

pull/2766/head
Rachael Booth 1 year ago committed by GitHub
parent
commit
152133e821
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/subsections/setup.rb
  2. 10
      config/locales/forms/2025/sales/setup.en.yml
  3. 2
      spec/factories/scheme.rb
  4. 34
      spec/models/form/sales/subsections/setup_spec.rb
  5. 18
      spec/requests/locations_controller_spec.rb

2
app/models/form/sales/subsections/setup.rb

@ -15,7 +15,7 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection
Form::Sales::Pages::OwnershipScheme.new(nil, nil, self), Form::Sales::Pages::OwnershipScheme.new(nil, nil, self),
Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self), Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self), Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self), (Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self) unless form.start_year_2025_or_later?),
Form::Sales::Pages::BuyerCompany.new(nil, nil, self), Form::Sales::Pages::BuyerCompany.new(nil, nil, self),
Form::Sales::Pages::BuyerLive.new(nil, nil, self), Form::Sales::Pages::BuyerLive.new(nil, nil, self),
Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::JointPurchase.new(nil, nil, self),

10
config/locales/forms/2025/sales/setup.en.yml

@ -50,16 +50,6 @@ en:
check_answer_label: "Type of discounted ownership sale" check_answer_label: "Type of discounted ownership sale"
hint_text: "" hint_text: ""
question_text: "What is the type of discounted ownership sale?" question_text: "What is the type of discounted ownership sale?"
outright_ownership:
page_header: "Type of outright sale"
type:
check_answer_label: "Type of outright sale"
hint_text: ""
question_text: "What is the type of outright sale?"
othtype:
check_answer_label: "Type of other sale"
hint_text: ""
question_text: "What type of sale is it?"
companybuy: companybuy:
page_header: "" page_header: ""

2
spec/factories/scheme.rb

@ -1,6 +1,6 @@
FactoryBot.define do FactoryBot.define do
factory :scheme do factory :scheme do
service_name { Faker::Name.name } service_name { "#{Faker::Name.name}'s Housing & Co." }
sensitive { Faker::Number.within(range: 0..1) } sensitive { Faker::Number.within(range: 0..1) }
registered_under_care_act { 1 } registered_under_care_act { 1 }
support_type { [0, 2, 3, 4, 5].sample } support_type { [0, 2, 3, 4, 5].sample }

34
spec/models/form/sales/subsections/setup_spec.rb

@ -23,6 +23,7 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
context "when start year is before 2024" do context "when start year is before 2024" do
before do before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(false) allow(section.form).to receive(:start_year_2024_or_later?).and_return(false)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
@ -46,9 +47,10 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
end end
end end
context "when start year is >= 2024" do context "when start year is 2024" do
before do before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(true) allow(section.form).to receive(:start_year_2024_or_later?).and_return(true)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
@ -75,4 +77,34 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
) )
end end
end end
context "when start year is >= 2025" do
before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(true)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
%w[
completion_date
owning_organisation
managing_organisation
assigned_to
purchaser_code
ownership_scheme
shared_ownership_type
discounted_ownership_type
buyer_company
buyer_live
joint_purchase
number_joint_buyers
buyer_interview_joint_purchase
buyer_interview
privacy_notice_joint_purchase
privacy_notice
],
)
end
end
end end

18
spec/requests/locations_controller_spec.rb

@ -180,7 +180,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a data coordinator user" do context "when signed in as a data coordinator user" do
let(:user) { create(:user, :data_coordinator) } let(:user) { create(:user, :data_coordinator) }
let(:scheme) { create(:scheme, owning_organisation: user.organisation, service_name: "Some name") } let(:scheme) { create(:scheme, owning_organisation: user.organisation) }
let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) } let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) }
before do before do
@ -215,7 +215,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct title" do it "has correct title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -232,7 +232,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do it "has correct page 1 of 2 title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -254,7 +254,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 2 of 2 title" do it "has correct page 2 of 2 title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -287,7 +287,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has search in the title" do it "has search in the title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page.title).to eq(expected_title) expect(page.title).to eq(expected_title)
end end
end end
@ -343,7 +343,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct title" do it "has correct title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -360,7 +360,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do it "has correct page 1 of 2 title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -382,7 +382,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do it "has correct page 1 of 2 title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
@ -415,7 +415,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has search in the title" do it "has search in the title" do
expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title(expected_title) expect(page).to have_title(expected_title)
end end
end end

Loading…
Cancel
Save