Validate parameters when active is false
This commit is contained in:
parent
602d09ffe8
commit
5d8ee3ed1c
1 changed files with 3 additions and 7 deletions
|
@ -10,9 +10,9 @@ module Ci
|
||||||
has_one :last_pipeline, -> { order(id: :desc) }, class_name: 'Ci::Pipeline'
|
has_one :last_pipeline, -> { order(id: :desc) }, class_name: 'Ci::Pipeline'
|
||||||
has_many :pipelines
|
has_many :pipelines
|
||||||
|
|
||||||
validates :cron, unless: :importing_or_inactive?, cron: true, presence: { unless: :importing_or_inactive? }
|
validates :cron, unless: :importing?, cron: true, presence: { unless: :importing? }
|
||||||
validates :cron_timezone, cron_timezone: true, presence: { unless: :importing_or_inactive? }
|
validates :cron_timezone, cron_timezone: true, presence: { unless: :importing? }
|
||||||
validates :ref, presence: { unless: :importing_or_inactive? }
|
validates :ref, presence: { unless: :importing? }
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|
||||||
before_save :set_next_run_at
|
before_save :set_next_run_at
|
||||||
|
@ -32,10 +32,6 @@ module Ci
|
||||||
update_attribute(:active, false)
|
update_attribute(:active, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def importing_or_inactive?
|
|
||||||
importing? || inactive?
|
|
||||||
end
|
|
||||||
|
|
||||||
def runnable_by_owner?
|
def runnable_by_owner?
|
||||||
Ability.allowed?(owner, :create_pipeline, project)
|
Ability.allowed?(owner, :create_pipeline, project)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue