| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -1893,6 +1893,22 @@ RSpec.describe CaseLog do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      end | 
					 | 
					 | 
					 | 
					      end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    end | 
					 | 
					 | 
					 | 
					    end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    context "when filtering by organisation" do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let(:organisation_1) { FactoryBot.create(:organisation) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let(:organisation_2) { FactoryBot.create(:organisation) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let(:organisation_3) { FactoryBot.create(:organisation) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let!(:case_log_1) { FactoryBot.create(:case_log, :in_progress, owning_organisation: organisation_1, managing_organisation: organisation_1) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let!(:case_log_2) { FactoryBot.create(:case_log, :completed, owning_organisation: organisation_1, managing_organisation: organisation_2) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let!(:case_log_3) { FactoryBot.create(:case_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_1) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      let!(:case_log_4) { FactoryBot.create(:case_log, :completed, owning_organisation: organisation_2, managing_organisation: organisation_2) } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      it "filters by given organisation" do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        expect(described_class.filter_by_organisation([organisation_1]).count).to eq(3) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        expect(described_class.filter_by_organisation([organisation_1, organisation_2]).count).to eq(4) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        expect(described_class.filter_by_organisation([organisation_3]).count).to eq(0) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    end | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    context "when filtering on status" do | 
					 | 
					 | 
					 | 
					    context "when filtering on status" do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      it "allows filtering on a single status" do | 
					 | 
					 | 
					 | 
					      it "allows filtering on a single status" do | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        expect(described_class.filter_by_status(%w[in_progress]).count).to eq(2) | 
					 | 
					 | 
					 | 
					        expect(described_class.filter_by_status(%w[in_progress]).count).to eq(2) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |