Skip to content

Commit 0cfaf99

Browse files
authored
Merge pull request #9445 from agrare/add_spec_coverage_catalog_controller_set_form_vars
Add tests for CatalogController#set_form_vars
2 parents 894a165 + acf79f4 commit 0cfaf99

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

spec/controllers/catalog_controller_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,55 @@
11651165
controller.send(:set_form_vars)
11661166
expect(controller.instance_variable_get(:@edit)[:new][:dialog_id]).to be_nil
11671167
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
11681217
end
11691218

11701219
describe '#get_form_vars' do

0 commit comments

Comments
 (0)