|
1165 | 1165 | controller.send(:set_form_vars)
|
1166 | 1166 | expect(controller.instance_variable_get(:@edit)[:new][:dialog_id]).to be_nil
|
1167 | 1167 | end
|
| 1168 | + |
| 1169 | + context "with a ServiceTemplateOrchestration" do |
| 1170 | + let(:record) { FactoryBot.create(:service_template_orchestration) } |
| 1171 | + |
| 1172 | + context "with no orchestration templates" do |
| 1173 | + it "sets available_templates to empty array" do |
| 1174 | + controller.send(:set_form_vars) |
| 1175 | + expect(controller.instance_variable_get(:@edit)[:new][:available_templates]).to be_empty |
| 1176 | + end |
| 1177 | + end |
| 1178 | + |
| 1179 | + context "with an orchestration template" do |
| 1180 | + let!(:orchestration_template) { FactoryBot.create(:orchestration_template_amazon) } |
| 1181 | + |
| 1182 | + it "sets available_templates" do |
| 1183 | + controller.send(:set_form_vars) |
| 1184 | + expect(controller.instance_variable_get(:@edit)[:new][:available_templates]).to eq([[orchestration_template.name, orchestration_template.id]]) |
| 1185 | + end |
| 1186 | + |
| 1187 | + context "that is selected" do |
| 1188 | + let!(:ems) { FactoryBot.create(:ems_amazon) } |
| 1189 | + let(:record) { FactoryBot.create(:service_template_orchestration, :orchestration_template => orchestration_template) } |
| 1190 | + |
| 1191 | + it "sets available_managers" do |
| 1192 | + controller.send(:set_form_vars) |
| 1193 | + expect(controller.instance_variable_get(:@edit)[:new][:available_managers]).to eq([[ems.name, ems.id]]) |
| 1194 | + end |
| 1195 | + end |
| 1196 | + end |
| 1197 | + end |
| 1198 | + |
| 1199 | + context "with a ServiceTemplateAnsibleTower" do |
| 1200 | + let!(:ems_ansible_tower) { FactoryBot.create(:provider_ansible_tower).automation_manager } |
| 1201 | + let(:record) { FactoryBot.create(:service_template_ansible_tower) } |
| 1202 | + |
| 1203 | + it "sets available_managers" do |
| 1204 | + controller.send(:set_form_vars) |
| 1205 | + expect(controller.instance_variable_get(:@edit)[:new][:available_managers]).to eq([[ems_ansible_tower.name, ems_ansible_tower.id]]) |
| 1206 | + end |
| 1207 | + |
| 1208 | + context "with other automation managers" do |
| 1209 | + let!(:embedded_ansible) { FactoryBot.create(:provider_embedded_ansible).automation_manager } |
| 1210 | + |
| 1211 | + it "doesn't include other automation managers" do |
| 1212 | + controller.send(:set_form_vars) |
| 1213 | + expect(controller.instance_variable_get(:@edit)[:new][:available_managers]).to eq([[ems_ansible_tower.name, ems_ansible_tower.id]]) |
| 1214 | + end |
| 1215 | + end |
| 1216 | + end |
1168 | 1217 | end
|
1169 | 1218 |
|
1170 | 1219 | describe '#get_form_vars' do
|
|
0 commit comments