| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | require 'db/mongo/models/report' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RSpec.describe Devops::Model::Report, type: :model do | 
					
						
							|  |  |  |   let(:report) { build(:report) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe '#initialize' do | 
					
						
							| 
									
										
										
										
											2015-11-30 16:51:43 +03:00
										 |  |  |     let(:given_moment) { Time.new(2007,11,1,15,25,0, "+01:00") } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     it 'converts created_at to localtime' do | 
					
						
							| 
									
										
										
										
											2015-11-30 16:51:43 +03:00
										 |  |  |       converted = build(:report, created_at: given_moment).created_at | 
					
						
							|  |  |  |       expect(converted).to eq given_moment.localtime | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it 'converts updated_at to localtime' do | 
					
						
							| 
									
										
										
										
											2015-11-30 16:51:43 +03:00
										 |  |  |       converted = build(:report, updated_at: given_moment).updated_at | 
					
						
							|  |  |  |       expect(converted).to eq given_moment.localtime | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe '#to_hash_without_id' do | 
					
						
							|  |  |  |     it 'contains several fields' do | 
					
						
							|  |  |  |       expect(report.to_hash_without_id.keys).to match_array(%w(
 | 
					
						
							|  |  |  |         file | 
					
						
							|  |  |  |         created_at | 
					
						
							|  |  |  |         updated_at | 
					
						
							|  |  |  |         created_by | 
					
						
							|  |  |  |         project | 
					
						
							|  |  |  |         deploy_env | 
					
						
							|  |  |  |         type | 
					
						
							|  |  |  |         chef_node_name | 
					
						
							|  |  |  |         host | 
					
						
							|  |  |  |         status | 
					
						
							|  |  |  |         stack | 
					
						
							|  |  |  |         subreports | 
					
						
							|  |  |  |         job_result_code | 
					
						
							|  |  |  |       )) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |