Skip to content

Commit

Permalink
RUBY-2729: increasing test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
brujeo committed Oct 3, 2023
1 parent 62c357c commit 2857a8e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/lib/pafs_core/data_migration/add_rfcc_codes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe PafsCore::DataMigration::AddRfccCodes do

describe "#up" do
it "updates RFCC codes for PSO records" do
pso = build(:pso_area, name: "PSO Berkshire and Buckinghamshire", sub_type: nil)
pso.save!(validate: false)

described_class.up
expect(pso.reload.sub_type).to eq("TH")
end
end

describe "#down" do
it "removes RFCC codes from PSOuthorities records" do
pso = create(:pso_area, name: "PSO Berkshire and Buckinghamshire", sub_type: "TH")
described_class.down
expect(pso.reload.sub_type).to eq("TH")
end
end
end
29 changes: 29 additions & 0 deletions spec/lib/pafs_core/data_migration/update_authorities_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe PafsCore::DataMigration::UpdateAuthorities do

describe "#up" do
it "adds authorities records if not present" do
expect(PafsCore::Area.authorities.count).to eq(0)
described_class.up
expect(PafsCore::Area.authorities.count).to eq(7)
end

it "adds missing authorities records" do
create(:authority, name: "Environment Agency", identifier: "EA")
expect(PafsCore::Area.authorities.count).to eq(1)
described_class.up
expect(PafsCore::Area.authorities.count).to eq(7)
end
end

describe "#down" do
it "removes authorities records" do
create(:authority, name: "Environment Agency", identifier: "EA")
described_class.down
expect(PafsCore::Area.authorities.count).to eq(0)
end
end
end

0 comments on commit 2857a8e

Please sign in to comment.