Browse Source

Unit test

pull/484/head
baarkerlounger 3 years ago
parent
commit
6f6496ceaa
  1. 2
      app/models/form_handler.rb
  2. 1
      spec/models/local_authority_spec.rb
  3. 14
      spec/models/organisation_spec.rb

2
app/models/form_handler.rb

@ -11,7 +11,7 @@ class FormHandler
end end
def current_form def current_form
forms[forms.keys.sort { |a, b| a.to_i <=> b.to_i }.last] forms[forms.keys.max_by(&:to_i)]
end end
private private

1
spec/models/local_authority_spec.rb

@ -3,6 +3,7 @@ require "rails_helper"
RSpec.describe LocalAuthority, type: :model do RSpec.describe LocalAuthority, type: :model do
describe "ons code mapping" do describe "ons code mapping" 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_form).and_return(form)
end end

14
spec/models/organisation_spec.rb

@ -30,8 +30,22 @@ RSpec.describe Organisation, type: :model do
end end
context "when the organisation only operates in specific local authorities" do context "when the organisation only operates in specific local authorities" do
let(:ons_code_mappings) do
{
"" => "Select an option",
"E07000223" => "Adur",
"E09000023" => "Lewisham",
"E08000003" => "Manchester",
"E07000178" => "Oxford",
"E07000114" => "Thanet",
"E09000033" => "Westminster",
"E06000014" => "York"
}
end
before do before do
FactoryBot.create(:organisation_la, organisation_id: organisation.id, ons_code: "E07000178") FactoryBot.create(:organisation_la, organisation_id: organisation.id, ons_code: "E07000178")
allow(LocalAuthority).to receive(:ons_code_mappings).and_return(ons_code_mappings)
end end
it "has local authorities associated" do it "has local authorities associated" do

Loading…
Cancel
Save