-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
spec/lib/pafs_core/data_migration/update_authorities_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |