diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-09 12:22:13 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-09 12:22:13 +0000 |
commit | e960931828b85205f2355c6040ec48ca14740e48 (patch) | |
tree | bdb5acefbde0f8d16bea556f427790114d61a9da | |
parent | 58086f822f181f49c309458d8357f96236d6cf4d (diff) | |
parent | 89ec120f61f8becb79403e7ad0a26fc8b942b57b (diff) | |
download | gitlab-ce-e960931828b85205f2355c6040ec48ca14740e48.tar.gz |
Merge branch '46010-runner-type-not-null' into 'master'
Set `ci_runners.runner_type` not null
See merge request gitlab-org/gitlab-ce!18825
-rw-r--r-- | app/models/ci/runner.rb | 1 | ||||
-rw-r--r-- | db/migrate/20180508135515_set_runner_type_not_null.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/runners.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/runner_spec.rb | 1 |
5 files changed, 15 insertions, 2 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 23078f1c3ed..ed8b30dae49 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -58,6 +58,7 @@ module Ci validate :tag_constraints validate :either_projects_or_group validates :access_level, presence: true + validates :runner_type, presence: true acts_as_taggable diff --git a/db/migrate/20180508135515_set_runner_type_not_null.rb b/db/migrate/20180508135515_set_runner_type_not_null.rb new file mode 100644 index 00000000000..dd043ec7179 --- /dev/null +++ b/db/migrate/20180508135515_set_runner_type_not_null.rb @@ -0,0 +1,9 @@ +class SetRunnerTypeNotNull < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + change_column_null(:ci_runners, :runner_type, false) + end +end diff --git a/db/schema.rb b/db/schema.rb index 6fd10785d77..839a5f6699a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180508055821) do +ActiveRecord::Schema.define(version: 20180508135515) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -497,7 +497,7 @@ ActiveRecord::Schema.define(version: 20180508055821) do t.integer "access_level", default: 0, null: false t.string "ip_address" t.integer "maximum_timeout" - t.integer "runner_type", limit: 2 + t.integer "runner_type", limit: 2, null: false end add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb index 34b8b246d0f..cdc170b9ccb 100644 --- a/spec/factories/ci/runners.rb +++ b/spec/factories/ci/runners.rb @@ -6,6 +6,7 @@ FactoryBot.define do is_shared false active true access_level :not_protected + runner_type :project_type trait :online do contacted_at Time.now @@ -13,6 +14,7 @@ FactoryBot.define do trait :shared do is_shared true + runner_type :instance_type end trait :specific do diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index fa9dff1c0f1..eb59ba7cbe9 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Ci::Runner do describe 'validation' do it { is_expected.to validate_presence_of(:access_level) } + it { is_expected.to validate_presence_of(:runner_type) } context 'when runner is not allowed to pick untagged jobs' do context 'when runner does not have tags' do |