Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
1.4 KiB

require "rails_helper"
RSpec.describe Scheme, type: :model do
describe "#new" do
let(:scheme) { FactoryBot.create(:scheme) }
it "belongs to an organisation" do
expect(scheme.organisation).to be_a(Organisation)
end
describe "scopes" do
let!(:scheme_1) { FactoryBot.create(:scheme) }
let!(:scheme_2) { FactoryBot.create(:scheme) }
context "when searching by code" do
it "returns case insensitive matching records" do
expect(described_class.search_by_code(scheme_1.code.upcase).count).to eq(1)
expect(described_class.search_by_code(scheme_1.code.downcase).count).to eq(1)
expect(described_class.search_by_code(scheme_2.code.upcase).count).to eq(1)
expect(described_class.search_by_code(scheme_2.code.downcase).count).to eq(1)
end
end
context "when searching by service name" do
it "returns case insensitive matching records" do
expect(described_class.search_by_organisation(scheme_1.organisation.name.upcase).count).to eq(1)
expect(described_class.search_by_organisation(scheme_1.organisation.name.downcase).count).to eq(1)
expect(described_class.search_by_organisation(scheme_2.organisation.name.upcase).count).to eq(1)
expect(described_class.search_by_organisation(scheme_2.organisation.name.downcase).count).to eq(1)
end
end
end
end
end