|
|
|
@ -1863,7 +1863,7 @@ RSpec.describe CaseLog do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "scopes" do |
|
|
|
|
describe "Searching scopes" do |
|
|
|
|
let!(:case_log_1) { FactoryBot.create(:case_log, :in_progress, startdate: Time.utc(2021, 5, 3), created_by: created_by_user, postcode_full: "XX12YY") } |
|
|
|
|
let!(:case_log_2) { FactoryBot.create(:case_log, :completed, startdate: Time.utc(2021, 5, 3), created_by: created_by_user) } |
|
|
|
|
|
|
|
|
@ -1871,38 +1871,38 @@ RSpec.describe CaseLog do
|
|
|
|
|
FactoryBot.create(:case_log, startdate: Time.utc(2022, 6, 3)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "searching scopes" do |
|
|
|
|
context "when searching scopes" do |
|
|
|
|
let!(:case_log_3) { FactoryBot.create(:case_log, :completed, startdate: Time.utc(2021, 5, 3), created_by: created_by_user, postcode_full: "XX12YY") } |
|
|
|
|
|
|
|
|
|
context "#filter_by_id" do |
|
|
|
|
describe "#filter_by_id" do |
|
|
|
|
it "allows searching by a log ID" do |
|
|
|
|
expect(described_class.filter_by_id(case_log_1.id.to_s).count).to eq(1) |
|
|
|
|
expect(described_class.filter_by_id(case_log_1.id.to_s).first.id).to eq case_log_1.id |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "#filter_by_tenancy_code" do |
|
|
|
|
describe "#filter_by_tenancy_code" do |
|
|
|
|
it "allows searching by a Tenancy Code" do |
|
|
|
|
expect(described_class.filter_by_tenancy_code(case_log_2.tenancy_code).count).to eq(1) |
|
|
|
|
expect(described_class.filter_by_tenancy_code(case_log_2.tenancy_code).first.id).to eq case_log_2.id |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "#filter_by_propcode" do |
|
|
|
|
describe "#filter_by_propcode" do |
|
|
|
|
it "allows searching by a Property Reference" do |
|
|
|
|
expect(described_class.filter_by_propcode(case_log_2.propcode).count).to eq(1) |
|
|
|
|
expect(described_class.filter_by_propcode(case_log_2.propcode).first.id).to eq case_log_2.id |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "#filter_by_postcode" do |
|
|
|
|
describe "#filter_by_postcode" do |
|
|
|
|
it "allows searching by a Property Postcode" do |
|
|
|
|
expect(described_class.filter_by_postcode(case_log_2.postcode_full).count).to eq(1) |
|
|
|
|
expect(described_class.filter_by_postcode(case_log_2.postcode_full).first.id).to eq case_log_2.id |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "#filter_by" do |
|
|
|
|
describe "#filter_by" do |
|
|
|
|
it "allows searching using ID" do |
|
|
|
|
expect(described_class.filter_by(case_log_1.id.to_s).count).to eq(1) |
|
|
|
|
expect(described_class.filter_by(case_log_1.id.to_s).first.id).to eq case_log_1.id |
|
|
|
@ -1924,7 +1924,7 @@ RSpec.describe CaseLog do
|
|
|
|
|
expect(described_class.filter_by(case_log_1.postcode_full).last.id).to eq case_log_3.id |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "postcode has spaces and lower case letters" do |
|
|
|
|
context "when postcode has spaces and lower case letters" do |
|
|
|
|
let(:matching_postcode_lower_case_with_spaces) { case_log_2.postcode_full.downcase.chars.insert(3, " ").join } |
|
|
|
|
|
|
|
|
|
it "allows searching by a Property Postcode" do |
|
|
|
|