@ -3,10 +3,12 @@ require "rails_helper"
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					RSpec . describe  OrganisationsHelper  do  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  include  TagHelper   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  describe  " display_organisation_attributes "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :organisation )  {  create ( :organisation ,  :la ,  :holds_own_stock ,  address_line1 :  " 2 Marsham Street " ,  address_line2 :  " London " ,  postcode :  " SW1P 4DF " ,  housing_registration_no :  1234 ,  organisation_rent_periods :  [ ] )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :support_user )  {  create ( :user ,  :support )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :coordinator_user )  {  create ( :user ,  :data_coordinator )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :organisation )  {  create ( :organisation ,  :la ,  :holds_own_stock ,  address_line1 :  " 2 Marsham Street " ,  address_line2 :  " London " ,  postcode :  " SW1P 4DF " ,  housing_registration_no :  1234 ,  organisation_rent_periods :  [ ] ,  group_member :  true ,  group_member_id :  99 ,  group :  1 )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    it  " has the correct values "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      expect ( display_organisation_attributes ( organisation ) ) . to  eq (   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    it  " has the correct values and editable status for support users  "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      expect ( display_organisation_attributes ( support_user ,  organisation ) ) . to  eq (   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        [ {  editable :  false ,  name :  " Organisation ID " ,  value :  " ORG #{ organisation . id } "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					           name :  " Address " ,   
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -15,6 +17,28 @@ RSpec.describe OrganisationsHelper do
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Registration number " ,  value :  " 1234 "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Type of provider " ,  value :  " Local authority "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Owns housing stock " ,  value :  " Yes "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  name :  " Part of group " ,  value :  " Yes "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  name :  " Group number " ,  value :  " GROUP1 "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  name :  " For profit " ,  value :  " "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  format :  :bullet ,  name :  " Rent periods " ,  value :  [ ]  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  name :  " Data Sharing Agreement "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Status " ,  value :  status_tag ( organisation . status )  } ] ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    it  " has the correct values and editable status for non-support users "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      expect ( display_organisation_attributes ( coordinator_user ,  organisation ) ) . to  eq (   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        [ {  editable :  false ,  name :  " Organisation ID " ,  value :  " ORG #{ organisation . id } "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					           name :  " Address " ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					           value :  " 2 Marsham Street \n London \n SW1P 4DF "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  name :  " Telephone number " ,  value :  nil  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Registration number " ,  value :  " 1234 "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Type of provider " ,  value :  " Local authority "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Owns housing stock " ,  value :  " Yes "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Part of group " ,  value :  " Yes "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Group number " ,  value :  " GROUP1 "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " For profit " ,  value :  " "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  true ,  format :  :bullet ,  name :  " Rent periods " ,  value :  [ ]  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  name :  " Data Sharing Agreement "  } ,   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					         {  editable :  false ,  name :  " Status " ,  value :  status_tag ( organisation . status )  } ] ,   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -56,4 +80,36 @@ RSpec.describe OrganisationsHelper do
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  describe  " # group_organisation_options_name "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :older_org )  {  create ( :organisation ,  group_member :  true ,  group_member_id :  123 ,  group :  9 )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    let ( :org )  {  create ( :organisation ,  name :  " Org1 " ,  group_member :  true ,  group_member_id :  older_org . id )  }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    it  " returns the organisation name with group text "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      allow ( org ) . to  receive ( :oldest_group_member ) . and_return ( older_org )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      name  =  helper . group_organisation_options_name ( org )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      expect ( name ) . to  eq ( " Org1 (GROUP9) " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  describe  " # profit_status_options "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    it  " returns a list of profit statuses with a null option "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      options  =  helper . profit_status_options   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      expect ( options . map ( & :name ) ) . to  include ( " Select an option " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    context  " when provider type is LA "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      it  " returns only the local authority option "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        options  =  helper . profit_status_options ( " LA " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        expect ( options . map ( & :id ) ) . to  eq ( [ " " ,  :local_authority ] )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    context  " when provider type is PRP "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      it  " excludes the local authority option "  do   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        options  =  helper . profit_status_options ( " PRP " )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        expect ( options . map ( & :id ) ) . not_to  include ( :local_authority )   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					      end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					  end   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					end