| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | require 'db/mongo/models/key' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RSpec.describe Devops::Model::Key, type: :model do | 
					
						
							|  |  |  |   let(:key) { build(:key) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it 'is valid with correct attrs' do | 
					
						
							|  |  |  |     expect(key).to be_valid | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-27 11:29:49 +03:00
										 |  |  |   describe 'validations', stubbed_logger: true do | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |     it 'key file should exist in file system' do | 
					
						
							|  |  |  |       expect(build(:key, path: './not_exist')).not_to be_valid | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "scope could be 'user' or 'system'" do | 
					
						
							|  |  |  |       expect(build(:key, scope: 'system')).to be_valid | 
					
						
							|  |  |  |       expect(build(:key, scope: 'wrong')).not_to be_valid | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it '#filename returns base name of key file' do | 
					
						
							|  |  |  |     expect(key.filename).to eq('blank_file') | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it '#to_hash_without_id returns path and scope' do | 
					
						
							|  |  |  |     expect(key.to_hash_without_id.keys).to eq(%w(path scope)) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |