Sha256: d64eff7154175550c8031c28e30d690b4bffbbfc5a3fa53bb3bde84a8e8dd53a

Contents?: true

Size: 816 Bytes

Versions: 58

Compression:

Stored size: 816 Bytes

Contents

module Katello
  module Validators
    class PriorValidator < ActiveModel::Validator
      def validate(record)
        #need to ensure that prior
        #environment already does not have a successor
        #this is because in v1.0 we want
        # prior to have only one child (unless its the Library)
        has_no_prior = true
        if record.organization
          has_no_prior = record.organization.kt_environments.reject { |env| env == record || env.prior != record.prior || env.prior == env.organization.library }.empty?
        end
        record.errors[:prior] << _("environment can only have one child") unless has_no_prior

        # only Library can have prior=nil
        record.errors[:prior] << _("environment required") unless !record.prior.nil? || record.library?
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
katello-3.7.0.rc1 app/lib/katello/validators/prior_validator.rb
katello-3.5.2 app/lib/katello/validators/prior_validator.rb
katello-3.6.0 app/lib/katello/validators/prior_validator.rb
katello-3.6.0.1.rc2 app/lib/katello/validators/prior_validator.rb
katello-3.6.0.rc2 app/lib/katello/validators/prior_validator.rb
katello-3.6.0.rc1 app/lib/katello/validators/prior_validator.rb
katello-3.5.1.1 app/lib/katello/validators/prior_validator.rb
katello-3.5.1 app/lib/katello/validators/prior_validator.rb
katello-3.5.0.1 app/lib/katello/validators/prior_validator.rb
katello-3.5.0 app/lib/katello/validators/prior_validator.rb
katello-3.5.0.rc2 app/lib/katello/validators/prior_validator.rb
katello-3.5.0.rc1 app/lib/katello/validators/prior_validator.rb
katello-3.4.5 app/lib/katello/validators/prior_validator.rb
katello-3.4.4 app/lib/katello/validators/prior_validator.rb
katello-3.4.2 app/lib/katello/validators/prior_validator.rb
katello-3.4.1 app/lib/katello/validators/prior_validator.rb
katello-3.4.0.2 app/lib/katello/validators/prior_validator.rb
katello-3.4.0.1 app/lib/katello/validators/prior_validator.rb
katello-3.3.2 app/lib/katello/validators/prior_validator.rb
katello-3.4.0 app/lib/katello/validators/prior_validator.rb