diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-04-04 16:55:14 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-04-06 23:46:58 +0900 |
commit | a67aff6d398467099121e7a7b4a542ff531d3f45 (patch) | |
tree | 310b68735bb6bee51319e8575c20e3d42e0cc297 | |
parent | 97cc6777368bfe171198af383bf715629e9b076f (diff) | |
download | gitlab-ce-a67aff6d398467099121e7a7b4a542ff531d3f45.tar.gz |
Add Import/Export Setting for trigger_schedule. Remove ref validation.
-rw-r--r-- | app/models/ci/trigger_schedule.rb | 9 | ||||
-rw-r--r-- | app/validators/ref_validator.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 3 | ||||
-rw-r--r-- | lib/gitlab/import_export/relation_factory.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/all_models.yml | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/safe_model_attributes.yml | 1 | ||||
-rw-r--r-- | spec/models/ci/trigger_schedule_spec.rb | 7 |
7 files changed, 11 insertions, 22 deletions
diff --git a/app/models/ci/trigger_schedule.rb b/app/models/ci/trigger_schedule.rb index be547af2114..58337b34d80 100644 --- a/app/models/ci/trigger_schedule.rb +++ b/app/models/ci/trigger_schedule.rb @@ -1,6 +1,7 @@ module Ci class TriggerSchedule < ActiveRecord::Base extend Ci::Model + include Importable acts_as_paranoid @@ -9,10 +10,10 @@ module Ci delegate :ref, to: :trigger - validates :trigger, presence: true - validates :cron, cron: true, presence: true - validates :cron_time_zone, presence: true - validates :ref, ref: true, presence: true + validates :trigger, presence: { unless: :importing? } + validates :cron, cron: true, presence: { unless: :importing? } + validates :cron_time_zone, presence: { unless: :importing? } + validates :ref, presence: { unless: :importing? } # validate :check_cron_frequency after_create :schedule_next_run! diff --git a/app/validators/ref_validator.rb b/app/validators/ref_validator.rb deleted file mode 100644 index 2024255a770..00000000000 --- a/app/validators/ref_validator.rb +++ /dev/null @@ -1,10 +0,0 @@ -# RefValidator -# -# Custom validator for Ref. -class RefValidator < ActiveModel::EachValidator - def validate_each(record, attribute, value) - unless record.project.repository.branch_exists?(value) - record.errors.add(attribute, " does not exist") - end - end -end diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 8d74418ed14..f5e1e385ff9 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -39,7 +39,8 @@ project_tree: - :author - :events - :statuses - - :triggers # TODO: Need to confirm + - triggers: + - :trigger_schedule - :deploy_keys - :services - :hooks diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb index fb43e7ccdbb..2ba12f5f924 100644 --- a/lib/gitlab/import_export/relation_factory.rb +++ b/lib/gitlab/import_export/relation_factory.rb @@ -5,6 +5,7 @@ module Gitlab pipelines: 'Ci::Pipeline', statuses: 'commit_status', triggers: 'Ci::Trigger', + trigger_schedule: 'Ci::TriggerSchedule', builds: 'Ci::Build', hooks: 'ProjectHook', merge_access_levels: 'ProtectedBranch::MergeAccessLevel', diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 06e8cd5a1cd..488ae9655bb 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -100,6 +100,8 @@ triggers: - trigger_requests - owner - trigger_schedule +trigger_schedule: +- trigger deploy_keys: - user - deploy_keys_projects diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index ecd8f2990c6..42082ff3dee 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -249,6 +249,7 @@ Ci::TriggerSchedule: - created_at - updated_at - cron +- cron_time_zone - next_run_at DeployKey: - id diff --git a/spec/models/ci/trigger_schedule_spec.rb b/spec/models/ci/trigger_schedule_spec.rb index 8b27ca1c8b2..99668ff17b8 100644 --- a/spec/models/ci/trigger_schedule_spec.rb +++ b/spec/models/ci/trigger_schedule_spec.rb @@ -5,13 +5,6 @@ describe Ci::TriggerSchedule, models: true do it { is_expected.to belong_to(:trigger) } it { is_expected.to respond_to :ref } - it 'should validate ref existence' do - trigger_schedule = create(:ci_trigger_schedule, :cron_nightly_build) - trigger_schedule.trigger.ref = 'invalid-ref' - trigger_schedule.valid? - expect(trigger_schedule.errors[:ref].first).to include('does not exist') - end - describe '#schedule_next_run!' do let(:trigger_schedule) { create(:ci_trigger_schedule, :cron_nightly_build, next_run_at: nil) } |