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