Commit 0a2f5065 authored by Dylan Griffith's avatar Dylan Griffith

Ensure we validate Runner#runner_type when persisting RunnerNamespace

parent ab489d29
...@@ -2,7 +2,7 @@ module Ci ...@@ -2,7 +2,7 @@ module Ci
class RunnerNamespace < ActiveRecord::Base class RunnerNamespace < ActiveRecord::Base
extend Gitlab::Ci::Model extend Gitlab::Ci::Model
belongs_to :runner belongs_to :runner, validate: true
belongs_to :namespace, class_name: '::Namespace' belongs_to :namespace, class_name: '::Namespace'
belongs_to :group, class_name: '::Group', foreign_key: :namespace_id belongs_to :group, class_name: '::Group', foreign_key: :namespace_id
end end
......
...@@ -66,6 +66,13 @@ describe Ci::Runner do ...@@ -66,6 +66,13 @@ describe Ci::Runner do
expect(instance_runner).not_to be_valid expect(instance_runner).not_to be_valid
expect(instance_runner.errors.full_messages).to include('Runner cannot assign project to a non-project runner') expect(instance_runner.errors.full_messages).to include('Runner cannot assign project to a non-project runner')
end end
it 'should fail to save a group assigned to a project runner even if the runner is already saved' do
group_runner
expect { create(:group, runners: [project_runner]) }
.to raise_error(ActiveRecord::RecordInvalid)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment