2016-06-10 17:36:54 -04:00
|
|
|
class Environment < ActiveRecord::Base
|
2016-06-15 09:09:50 -04:00
|
|
|
belongs_to :project, required: true, validate: true
|
2016-06-10 17:36:54 -04:00
|
|
|
|
|
|
|
has_many :deployments
|
|
|
|
|
2016-06-14 07:04:21 -04:00
|
|
|
validates :name,
|
|
|
|
presence: true,
|
2016-06-14 12:34:48 -04:00
|
|
|
uniqueness: { scope: :project_id },
|
2016-06-14 07:04:21 -04:00
|
|
|
length: { within: 0..255 },
|
|
|
|
format: { with: Gitlab::Regex.environment_name_regex,
|
|
|
|
message: Gitlab::Regex.environment_name_regex_message }
|
2016-06-10 17:36:54 -04:00
|
|
|
|
|
|
|
def last_deployment
|
|
|
|
deployments.last
|
|
|
|
end
|
|
|
|
end
|