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
def current_form
forms[forms.keys.sort { |a, b| a.to_i <=> b.to_i }.last]
forms[forms.keys.max_by(&:to_i)]
end
private

1
spec/models/local_authority_spec.rb

@ -3,6 +3,7 @@ require "rails_helper"
RSpec.describe LocalAuthority, type: :model do
describe "ons code mapping" do
let(:form) { Form.new("spec/fixtures/forms/2021_2022.json", "2021_2022") }
before do
allow(FormHandler.instance).to receive(:current_form).and_return(form)
end

14
spec/models/organisation_spec.rb

@ -30,8 +30,22 @@ RSpec.describe Organisation, type: :model do
end
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
FactoryBot.create(:organisation_la, organisation_id: organisation.id, ons_code: "E07000178")
allow(LocalAuthority).to receive(:ons_code_mappings).and_return(ons_code_mappings)
end
it "has local authorities associated" do

Loading…
Cancel
Save