Skip to content

Commit

Permalink
Merge pull request #3805 from h-kataria/fix_cloud_volumes_display_for…
Browse files Browse the repository at this point in the history
…_ems_stroage_manager

Added setting of `@ems` to fix the nilclass error.
(cherry picked from commit 9b6d7f0)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1570051
  • Loading branch information
mzazrivec authored and simaishi committed Apr 20, 2018
1 parent 1987641 commit a71cfe4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/ems_storage_controller.rb
Expand Up @@ -47,7 +47,7 @@ def type_feature_role_check
end

def init_show(model_class = self.class.model)
@record = identify_record(params[:id], model_class)
@ems = @record = identify_record(params[:id], model_class)

return true unless type_feature_role_check

Expand Down
10 changes: 10 additions & 0 deletions spec/controllers/ems_storage_controller_spec.rb
Expand Up @@ -32,5 +32,15 @@
controller.instance_variable_set(:@record, object_storage)
expect(controller.send(:type_feature_role_check)).to be_falsey
end

it "sets @ems in init_show for a selected record" do
controller.action_name = 'show'
ems_storage = FactoryGirl.create(:ems_storage, :name => "foo")
allow(controller).to receive(:type_feature_role_check).and_return(true)
controller.instance_variable_set(:@_params, :id => ems_storage.id)
controller.send(:init_show)
expect(assigns(:record).id).to eq(ems_storage.id)
expect(assigns(:ems).id).to eq(ems_storage.id)
end
end
end
20 changes: 20 additions & 0 deletions spec/views/shared/views/ems_common/_show.html.haml_spec.rb
Expand Up @@ -36,4 +36,24 @@
end
end
end

context "when display is 'cloud_volumes'" do
before do
allow(controller).to receive(:controller_name).and_return("ems_storage")
assign(:record, ems)
assign(:ems, ems)
assign(:display, display)
assign(:showtype, showtype)
allow(view).to receive(:render_gtl_outer)
end

let(:showtype) { "main" }
let(:display) {'cloud_volumes'}
let(:ems) { FactoryGirl.create(:ems_storage, :hostname => '1.1.1.1') }

it "should show render gtl for list of cloud_volumes" do
render
expect(view).to render_template(:partial => 'layouts/gtl', :locals => {:action_url => "show/#{ems.id}"})
end
end
end

0 comments on commit a71cfe4

Please sign in to comment.