| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | require 'db/mongo/models/deploy_env/deploy_env_static' | 
					
						
							| 
									
										
										
										
											2015-12-10 01:24:23 +03:00
										 |  |  | require_relative 'shared_deploy_env_specs' | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | RSpec.describe Devops::Model::DeployEnvStatic, type: :model do | 
					
						
							|  |  |  |   let(:env) { build(:deploy_env_static) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-10 01:24:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 17:47:07 +03:00
										 |  |  |   describe 'it inherits from deploy env', stubbed_logger: true, stubbed_connector: true do | 
					
						
							| 
									
										
										
										
											2015-12-10 01:24:23 +03:00
										 |  |  |     before do | 
					
						
							|  |  |  |       allow(Provider::ProviderFactory).to receive(:providers).and_return(%w(static)) | 
					
						
							| 
									
										
										
										
											2016-01-20 17:47:07 +03:00
										 |  |  |       allow(stubbed_connector).to receive(:users_names) { %w(root) } | 
					
						
							| 
									
										
										
										
											2015-12-10 01:24:23 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it_behaves_like 'deploy env' | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-18 21:24:26 +03:00
										 |  |  |     it "isn't valid if provider_account isn't present" do | 
					
						
							|  |  |  |       allow(stubbed_connector).to receive(:provider_accounts) do |provider| | 
					
						
							|  |  |  |         if provider == 'ec2' | 
					
						
							|  |  |  |           account_name = 'ec2_account' | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           account_name = 'static_account' | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |         [Provider::ProviderFactory.get_account_class(provider).new('account_name' => account_name)] | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       env.provider_account = 'ec2_account' | 
					
						
							|  |  |  |       expect(env).not_to be_valid | 
					
						
							|  |  |  |       env.provider_account = 'static_account' | 
					
						
							|  |  |  |       expect(env).to be_valid | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   describe '.create' do | 
					
						
							|  |  |  |     it 'returns instance of DeployEnvStatic' do | 
					
						
							|  |  |  |       expect(described_class.create({})).to be_an_instance_of(Devops::Model::DeployEnvStatic) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | end |