From 2c604819ca6a1e3744bbdeccf225b21fc5f91c9e Mon Sep 17 00:00:00 2001 From: Brian McLaughlin Date: Wed, 22 Jun 2016 16:35:56 -0400 Subject: [PATCH] Render correct partial for policy simulation detail page https://bugzilla.redhat.com/show_bug.cgi?id=1348341 --- app/views/vm/show.html.haml | 2 ++ spec/views/vm/_show.html.haml_spec.rb | 30 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 spec/views/vm/_show.html.haml_spec.rb diff --git a/app/views/vm/show.html.haml b/app/views/vm/show.html.haml index bbaa7487fc8..08438765231 100644 --- a/app/views/vm/show.html.haml +++ b/app/views/vm/show.html.haml @@ -11,3 +11,5 @@ = render :partial => "vm_common/live_migrate" - elsif @evacuate = render :partial => "vm_common/evacuate" + - else + = render :partial => "vm_common/#{@showtype}", :locals => {:controller => "vm"} diff --git a/spec/views/vm/_show.html.haml_spec.rb b/spec/views/vm/_show.html.haml_spec.rb new file mode 100644 index 00000000000..4f513c9ab3e --- /dev/null +++ b/spec/views/vm/_show.html.haml_spec.rb @@ -0,0 +1,30 @@ +describe "vm/show.html.haml" do + shared_examples_for "miq_before_onload JS is needed" do + it "renders proper JS" do + js_string = "var miq_after_onload = \"miqAsyncAjax('/vm/#{action}/#{vm.id}');\"" + render + expect(rendered).to include(js_string) + end + end + + let(:vm) { FactoryGirl.create(:vm, :name => 'vm', :description => 'vm description') } + let(:action) { 'show' } + + before do + assign(:record, vm) + assign(:ajax_action, action) + assign(:showtype, showtype) + end + + context "when showtype is 'policies'" do + let(:showtype) { 'policies' } + let(:display) { 'main' } + + it 'should render policies view' do + assign(:lastaction, 'policy_sim') + stub_template "vm_common/_policies.html.haml" => "Stubbed Content" + render + expect(rendered).to render_template(:partial => 'vm_common/policies', :locals => {:controller => 'vm'}) + end + end +end