Browse Source

lint

pull/2645/head
Kat 2 years ago committed by kosiakkatrina
parent
commit
64f7ed1217
  1. 20
      spec/lib/tasks/count_duplicates_spec.rb
  2. 9
      spec/models/location_spec.rb
  3. 14
      spec/models/scheme_spec.rb

20
spec/lib/tasks/count_duplicates_spec.rb

@ -2,6 +2,12 @@ require "rails_helper"
require "rake"
RSpec.describe "count_duplicates" do
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:write_file)
allow(storage_service).to receive(:get_presigned_url).and_return(test_url)
end
describe "count_duplicates:scheme_duplicates_per_org", type: :task do
subject(:task) { Rake::Task["count_duplicates:scheme_duplicates_per_org"] }
@ -12,14 +18,13 @@ RSpec.describe "count_duplicates" do
Rake.application.rake_require("tasks/count_duplicates")
Rake::Task.define_task(:environment)
task.reenable
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:write_file)
allow(storage_service).to receive(:get_presigned_url).and_return(test_url)
end
context "when the rake task is run" do
context "and there are no duplicate schemes" do
let!(:organisation) { create(:organisation) }
before do
create(:organisation)
end
it "creates a csv with headers only" do
expect(storage_service).to receive(:write_file).with(/scheme-duplicates-.*\.csv/, "\uFEFFOrganisation id,Number of duplicate sets,Total duplicate schemes\n")
@ -57,14 +62,13 @@ RSpec.describe "count_duplicates" do
Rake.application.rake_require("tasks/count_duplicates")
Rake::Task.define_task(:environment)
task.reenable
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:write_file)
allow(storage_service).to receive(:get_presigned_url).and_return(test_url)
end
context "when the rake task is run" do
context "and there are no duplicate locations" do
let!(:organisation) { create(:organisation) }
before do
create(:organisation)
end
it "creates a csv with headers only" do
expect(storage_service).to receive(:write_file).with(/location-duplicates-.*\.csv/, "\uFEFFOrganisation id,Number of duplicate sets,Total duplicate locations\n")

9
spec/models/location_spec.rb

@ -888,8 +888,13 @@ RSpec.describe Location, type: :model do
end
context "when there is a location with nil values for duplicate check fields" do
let!(:location) { build(:location, postcode: nil, mobility_type: nil, scheme:).save(validate: false) }
let!(:duplicate_location) { build(:location, postcode: nil, mobility_type: nil, scheme:).save(validate: false) }
before do
[location, duplicate_location].each do |l|
l.postcode = nil
l.mobility_type = nil
l.save!(validate: false)
end
end
it "does not return a location with nil values as a duplicate" do
expect(duplicate_sets).to be_empty

14
spec/models/scheme_spec.rb

@ -309,8 +309,18 @@ RSpec.describe Scheme, type: :model do
end
context "when there is a scheme with nil values for duplicate check fields" do
let!(:scheme) { build(:scheme, :duplicate, owning_organisation: organisation, scheme_type: nil, registered_under_care_act: nil, primary_client_group: nil, secondary_client_group: nil, has_other_client_group: nil, support_type: nil, intended_stay: nil).save(validate: false) }
let!(:duplicate_scheme) { build(:scheme, :duplicate, owning_organisation: organisation, scheme_type: nil, registered_under_care_act: nil, primary_client_group: nil, secondary_client_group: nil, has_other_client_group: nil, support_type: nil, intended_stay: nil).save(validate: false) }
before do
[scheme, duplicate_scheme].each do |s|
s.scheme_type = nil
s.registered_under_care_act = nil
s.primary_client_group = nil
s.secondary_client_group = nil
s.has_other_client_group = nil
s.support_type = nil
s.intended_stay = nil
s.save!(validate: false)
end
end
it "does not return a scheme with nil values as a duplicate" do
expect(duplicate_sets).to be_empty

Loading…
Cancel
Save