refactore validators
This commit is contained in:
parent
2cc89a8ac1
commit
f5aced5827
@ -20,10 +20,9 @@ class DeployEnvBase < MongoModel
|
||||
|
||||
def validate!
|
||||
super
|
||||
Validators::DeployEnv::RunList.new(self).validate!
|
||||
Validators::DeployEnv::Expiration.new(self).validate!
|
||||
|
||||
check_users!(self.users)
|
||||
self.class.validators.each do |validator|
|
||||
validator.new(self).validate!
|
||||
end
|
||||
end
|
||||
|
||||
def to_hash
|
||||
@ -36,4 +35,20 @@ class DeployEnvBase < MongoModel
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
# class methods
|
||||
class << self
|
||||
|
||||
def validators
|
||||
@validators
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_validators(*validators)
|
||||
@validators = validators
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -8,6 +8,10 @@ class DeployEnvStatic < DeployEnvBase
|
||||
:run_list => {:type => Array, :empty => true},
|
||||
:users => {:type => Array, :empty => true}
|
||||
|
||||
set_validators ::Validators::DeployEnv::RunList,
|
||||
::Validators::DeployEnv::Expiration,
|
||||
::Validators::DeployEnv::Users
|
||||
|
||||
def initialize d={}
|
||||
super(d)
|
||||
=begin
|
||||
@ -21,10 +25,6 @@ class DeployEnvStatic < DeployEnvBase
|
||||
=end
|
||||
end
|
||||
|
||||
def validate!
|
||||
super
|
||||
end
|
||||
|
||||
def to_hash
|
||||
super
|
||||
=begin
|
||||
|
||||
@ -8,8 +8,8 @@ require "fileutils"
|
||||
$:.push File.dirname(__FILE__)
|
||||
require "db/exceptions/invalid_record"
|
||||
require "db/exceptions/record_not_found"
|
||||
require "db/mongo/mongo_connector"
|
||||
require "db/validators/all"
|
||||
require "db/mongo/mongo_connector"
|
||||
require "providers/provider_factory"
|
||||
|
||||
require "routes/v2.0"
|
||||
|
||||
@ -101,7 +101,7 @@ Feature: Create deploy env
|
||||
Then response should be '400'
|
||||
|
||||
@static
|
||||
Scenario: Send deploy env with invalid user (not present in mongo) for project <%= project_name %>
|
||||
Scenario: Send deploy env with invalid user (missing in mongo) for project <%= project_name %>
|
||||
When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body
|
||||
"""
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user