Commit d8ad9572 authored by Thong Kuah's avatar Thong Kuah

Allow management_project_id to be unset

Add test showing the bug.
parent 145953c9
......@@ -23,7 +23,7 @@ module Clusters
end
def validate_params(cluster)
if params[:management_project_id]
if params[:management_project_id].present?
management_project = management_project_scope(cluster).find_by_id(params[:management_project_id])
unless management_project
......
......@@ -138,6 +138,23 @@ describe Clusters::UpdateService do
expect(cluster.management_project_id).to be_nil
end
end
context 'cluster already has a management project set' do
before do
cluster.update!(management_project: create(:project))
end
let(:params) do
{ management_project_id: '' }
end
it 'unsets management_project_id' do
is_expected.to eq(true)
cluster.reload
expect(cluster.management_project_id).to be_nil
end
end
end
context 'project cluster' do
......
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