Skip to content

Commit

Permalink
Add spec for the fix for changing the title in Instance Policy sim page
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilda Stastna committed Apr 11, 2019
1 parent 09be462 commit 8f5ec3f
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions spec/controllers/vm_common_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe VmOrTemplateController do
context "#snap_pressed" do
describe "#snap_pressed" do
before do
stub_user(:features => :all)
@vm = FactoryBot.create(:vm_vmware)
Expand Down Expand Up @@ -46,7 +46,7 @@
end
end

context '#reload ' do
describe '#reload ' do
before do
login_as FactoryBot.create(:user_with_group, :role => "operator")
allow(controller).to receive(:tree_select).and_return(nil)
Expand All @@ -63,7 +63,7 @@

end

context "#show" do
describe "#show" do
before do
allow(User).to receive(:server_timezone).and_return("UTC")
allow_any_instance_of(described_class).to receive(:set_user_time_zone)
Expand Down Expand Up @@ -179,7 +179,7 @@
end
end

context '#replace_right_cell' do
describe '#replace_right_cell' do
it 'should display form button on Migrate request screen' do
vm = FactoryBot.create(:vm_infra)
allow(controller).to receive(:params).and_return(:action => 'vm_migrate')
Expand All @@ -202,9 +202,25 @@
controller.send(:replace_right_cell, :action => 'migrate', :presenter => presenter)
expect(presenter[:update_partials]).to have_key(:form_buttons_div)
end

context 'Instance policy simulation' do
let(:vm_openstack) { FactoryBot.create(:vm_openstack, :ext_management_system => FactoryBot.create(:ems_openstack)) }

before do
allow(controller).to receive(:render)
controller.instance_variable_set(:@record, vm_openstack)
controller.instance_variable_set(:@sb, :action => 'policy_sim')
request.parameters[:controller] = 'vm_or_template'
end

it 'sets right cell text for policy simulation page' do
controller.send(:replace_right_cell)
expect(controller.instance_variable_get(:@right_cell_text)).to eq('Instance Policy Simulation')
end
end
end

context '#parent_folder_id' do
describe '#parent_folder_id' do
it 'returns id of orphaned folder for orphaned VM/Template' do
vm_orph = FactoryBot.create(:vm_infra, :storage => FactoryBot.create(:storage))
template_orph = FactoryBot.create(:template_infra, :storage => FactoryBot.create(:storage))
Expand Down Expand Up @@ -273,7 +289,7 @@
end
end

context "#resolve_node_info" do
describe "#resolve_node_info" do
let(:vm_common) do
Class.new do
extend VmCommon
Expand All @@ -291,7 +307,7 @@
end
end

context '#evm_relationship_get_form_vars' do
describe '#evm_relationship_get_form_vars' do
before do
@vm = FactoryBot.create(:vm_vmware)
edit = {:vm_id => @vm.id, :new => {:server => nil}}
Expand Down

0 comments on commit 8f5ec3f

Please sign in to comment.