mirror of
				https://github.com/fspc/bike-database.git
				synced 2025-10-31 00:35:35 -04:00 
			
		
		
		
	lk | bikes with voided applications show up in the available for freecyclery list
This commit is contained in:
		
							parent
							
								
									cc00aec5ad
								
							
						
					
					
						commit
						6119733ad7
					
				| @ -42,8 +42,12 @@ class Bike < ActiveRecord::Base | ||||
|   end | ||||
| 
 | ||||
|   def self.available_for_freecyclery | ||||
|     assigned_bikes = Client.all.includes(:bike).select{|c| !c.bike_id.nil?}.map(&:bike) | ||||
|     all_freecyclery_bikes = Bike.where(purpose: FREECYCLERY).order(log_number: :desc) | ||||
|     assigned_bikes = Client | ||||
|       .where("application_voided != ? or application_voided is null", true) | ||||
|       .includes(:bike) | ||||
|       .select{|c| !c.bike_id.nil?}.map(&:bike) | ||||
|     all_freecyclery_bikes = Bike.where(purpose: FREECYCLERY) | ||||
|                                 .order(log_number: :desc) | ||||
|     all_freecyclery_bikes - assigned_bikes | ||||
|   end | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										3
									
								
								notes.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								notes.md
									
									
									
									
									
								
							| @ -15,9 +15,6 @@ | ||||
| - enable posting to bike index when a bike is created | ||||
| - add tests to ensure that pages render | ||||
| 
 | ||||
| # Bugs | ||||
| - when application voided, bike should go back to pool of bikes | ||||
| 
 | ||||
| # Other | ||||
| Reports | ||||
|   General Reports | ||||
|  | ||||
| @ -31,6 +31,11 @@ describe Bike do | ||||
|       create :client, bike_id: bike.id | ||||
|       expect(Bike.available_for_freecyclery).to be_empty | ||||
|     end | ||||
|     it "returns bikes that were assigned to clients whose application has been voided" do | ||||
|       bike = create :bike, :freecyclery | ||||
|       create :client, bike_id: bike.id, application_voided: true | ||||
|       expect(Bike.available_for_freecyclery).to eq [bike] | ||||
|     end | ||||
|     it "does not return sales bikes" do | ||||
|       bike = create :bike, :sale | ||||
|       create :client, bike_id: bike.id | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user