|
|
|
|
@ -2769,6 +2769,25 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when filtering by owning organisation" do |
|
|
|
|
let(:organisation_1) { create(:organisation) } |
|
|
|
|
let(:organisation_2) { create(:organisation) } |
|
|
|
|
let(:organisation_3) { create(:organisation) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, :in_progress, owning_organisation: organisation_1, managing_organisation: organisation_1, created_by: nil) |
|
|
|
|
create(:lettings_log, :completed, owning_organisation: organisation_1, managing_organisation: organisation_2, created_by: nil) |
|
|
|
|
create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_1, created_by: nil) |
|
|
|
|
create(:lettings_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_2, created_by: nil) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "filters by given owning organisation" do |
|
|
|
|
expect(described_class.filter_by_owning_organisation([organisation_1]).count).to eq(2) |
|
|
|
|
expect(described_class.filter_by_owning_organisation([organisation_1, organisation_2]).count).to eq(4) |
|
|
|
|
expect(described_class.filter_by_owning_organisation([organisation_3]).count).to eq(0) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when filtering on status" do |
|
|
|
|
it "allows filtering on a single status" do |
|
|
|
|
expect(described_class.filter_by_status(%w[in_progress]).count).to eq(2) |
|
|
|
|
|