mirror of
				https://github.com/fspc/BikeShed-1.git
				synced 2025-10-31 08:55:36 -04:00 
			
		
		
		
	Create factory for seeding db with fake bikes, update seeds.rb
This commit is contained in:
		
							parent
							
								
									e41426ea7b
								
							
						
					
					
						commit
						885caefaf7
					
				
							
								
								
									
										12
									
								
								db/seeds.rb
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								db/seeds.rb
									
									
									
									
									
								
							| @ -19,6 +19,14 @@ if BikeBrand.all.empty? and BikeModel.all.empty? | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| if Rails.env.development? | if Rails.env.development? | ||||||
|   user = FactoryGirl.build(:user) | 
 | ||||||
|   FactoryGirl.create(:user) if not User.find_by_email(user.email) |   #create default dev user | ||||||
|  |   FactoryGirl.create(:user) if User.all.empty? | ||||||
|  | 
 | ||||||
|  |   #create fake bikes | ||||||
|  |   if Bike.all.empty? | ||||||
|  |     42.times do |n| | ||||||
|  |       FactoryGirl.create(:bike) | ||||||
|  |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								spec/factories/bikes.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								spec/factories/bikes.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | |||||||
|  | # Read about factories at https://github.com/thoughtbot/factory_girl | ||||||
|  | 
 | ||||||
|  | FactoryGirl.define do | ||||||
|  |   factory :bike do | ||||||
|  |     sequence :serial_number do |n| | ||||||
|  |       "S/N# #{n}" | ||||||
|  |     end | ||||||
|  |     bike_brand_id 1 | ||||||
|  |     bike_model_id 1 | ||||||
|  |     color "FFFFFF" | ||||||
|  |     bike_style_id 1 | ||||||
|  |     seat_tube_height 5 | ||||||
|  |     top_tube_length 6 | ||||||
|  |     wheel_size 27 | ||||||
|  |     value 100 | ||||||
|  |     bike_condition_id 1 | ||||||
|  |     bike_status_id 1 | ||||||
|  |   end | ||||||
|  | end | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user