Ensure we validate Runner#runner_type when persisting RunnerNamespace
This commit is contained in:
parent
ab489d293d
commit
0a2f5065f2
2 changed files with 8 additions and 1 deletions
|
@ -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
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue