change puts to logger in validators#base

This commit is contained in:
Anton Chuchkalov 2016-01-27 11:29:49 +03:00
parent ee9f097b0f
commit 5ab7f10028
9 changed files with 9 additions and 9 deletions

View File

@ -9,7 +9,7 @@ module Validators
def validate! def validate!
raise InvalidRecord.new(message) unless valid? raise InvalidRecord.new(message) unless valid?
rescue StandardError => e rescue StandardError => e
puts [e.message, e.backtrace].join("\n") DevopsLogger.logger.error [e.message, e.backtrace].join("\n")
raise InvalidRecord.new("An error raised during validation with #{self.class}: #{e.class}: #{e.message}") raise InvalidRecord.new("An error raised during validation with #{self.class}: #{e.class}: #{e.message}")
end end

View File

@ -5,7 +5,7 @@ require_relative 'shared_cloud_deploy_env_specs'
RSpec.describe Devops::Model::DeployEnvEc2, type: :model do RSpec.describe Devops::Model::DeployEnvEc2, type: :model do
let(:env) { build(:deploy_env_ec2) } let(:env) { build(:deploy_env_ec2) }
describe 'it inherits from cloud deploy_env', stubbed_env_validators: true do describe 'it inherits from cloud deploy_env', stubbed_env_validators: true, stubbed_logger: true do
it_behaves_like 'deploy env' it_behaves_like 'deploy env'
it_behaves_like 'cloud deploy env' it_behaves_like 'cloud deploy env'
end end

View File

@ -5,7 +5,7 @@ require_relative 'shared_cloud_deploy_env_specs'
RSpec.describe Devops::Model::DeployEnvOpenstack, type: :model do RSpec.describe Devops::Model::DeployEnvOpenstack, type: :model do
let(:env) { build(:deploy_env_openstack) } let(:env) { build(:deploy_env_openstack) }
describe 'it inherits from cloud deploy_env', stubbed_env_validators: true do describe 'it inherits from cloud deploy_env', stubbed_env_validators: true, stubbed_logger: true do
it_behaves_like 'deploy env' it_behaves_like 'deploy env'
it_behaves_like 'cloud deploy env' it_behaves_like 'cloud deploy env'
end end

View File

@ -15,7 +15,7 @@ RSpec.describe Devops::Model::Image, type: :model do
expect(image).to be_valid expect(image).to be_valid
end end
describe 'validation' do describe 'validation', stubbed_logger: true do
include_examples 'field type validation', :id, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :id, :not_nil, :non_empty_string, :field_validator
include_examples 'field type validation', :remote_user, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :remote_user, :not_nil, :non_empty_string, :field_validator
include_examples 'field type validation', :name, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :name, :not_nil, :non_empty_string, :field_validator

View File

@ -7,7 +7,7 @@ RSpec.describe Devops::Model::Key, type: :model do
expect(key).to be_valid expect(key).to be_valid
end end
describe 'validations' do describe 'validations', stubbed_logger: true do
it 'key file should exist in file system' do it 'key file should exist in file system' do
expect(build(:key, path: './not_exist')).not_to be_valid expect(build(:key, path: './not_exist')).not_to be_valid
end end

View File

@ -3,7 +3,7 @@ require 'db/mongo/models/project'
RSpec.describe Devops::Model::Project, type: :model do RSpec.describe Devops::Model::Project, type: :model do
let(:project) { build(:project) } let(:project) { build(:project) }
describe 'validation rules:', stubbed_env_validators: true do describe 'validation rules:', stubbed_env_validators: true, stubbed_logger: true do
include_examples 'field type validation', :id, :not_nil, :non_empty_string include_examples 'field type validation', :id, :not_nil, :non_empty_string
include_examples 'field type validation', :deploy_envs, :not_nil, :non_empty_array include_examples 'field type validation', :deploy_envs, :not_nil, :non_empty_array
include_examples 'field type validation', :description, :maybe_nil, :maybe_empty_string include_examples 'field type validation', :description, :maybe_nil, :maybe_empty_string

View File

@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Devops::Model::OpenstackProviderAccount, type: :model do RSpec.describe Devops::Model::OpenstackProviderAccount, type: :model do
let(:provider_account) { build(:openstack_provider_account) } let(:provider_account) { build(:openstack_provider_account) }
it "should not validate access_key_id" do it "should not validate access_key_id", stubbed_logger: true do
fields = described_class.field_validators.values.flatten.flatten.map{|t| t[:field]} fields = described_class.field_validators.values.flatten.flatten.map{|t| t[:field]}
expect(fields).not_to include(:access_key_id, :secret_access_key) expect(fields).not_to include(:access_key_id, :secret_access_key)
end end

View File

@ -11,7 +11,7 @@ RSpec.describe Devops::Model::Server, type: :model do
expect(server).to be_valid expect(server).to be_valid
end end
describe 'validation rules:' do describe 'validation rules:', stubbed_logger: true do
include_examples 'field type validation', :id, :not_nil, :non_empty_string include_examples 'field type validation', :id, :not_nil, :non_empty_string
include_examples 'field type validation', :provider, :not_nil, :non_empty_string include_examples 'field type validation', :provider, :not_nil, :non_empty_string
include_examples 'field type validation', :remote_user, :not_nil, :non_empty_string include_examples 'field type validation', :remote_user, :not_nil, :non_empty_string

View File

@ -11,7 +11,7 @@ RSpec.describe Devops::Model::StackEc2, type: :model do
expect(build(:stack_ec2)).to be_valid expect(build(:stack_ec2)).to be_valid
end end
describe 'validation rules:' do describe 'validation rules:', stubbed_logger: true do
include_examples 'field type validation', :id, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :id, :not_nil, :non_empty_string, :field_validator
include_examples 'field type validation', :project, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :project, :not_nil, :non_empty_string, :field_validator
include_examples 'field type validation', :deploy_env, :not_nil, :non_empty_string, :field_validator include_examples 'field type validation', :deploy_env, :not_nil, :non_empty_string, :field_validator