Skip to content

Commit

Permalink
Add tests for Tag, Manage policies and Check compliance buttons
Browse files Browse the repository at this point in the history
Add tests for the buttons for nested lists of Container Images/Nodes/Pods/Replicators.
  • Loading branch information
Hilda Stastna committed Jun 29, 2018
1 parent 7879ab1 commit b00c996
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions spec/controllers/ems_common_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def test_creating(emstype)
end
end

context "#update" do
describe "#update" do
context "updates provider with new token" do
before :each do
before do
stub_user(:features => :all)
session[:edit] = assigns(:edit)
end
Expand Down Expand Up @@ -202,8 +202,8 @@ def test_setting_few_fields
end
end

context "#button" do
before(:each) do
describe "#button" do
before do
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone
end
Expand Down Expand Up @@ -232,6 +232,57 @@ def test_setting_few_fields
post :button, :params => { :pressed => "vm_edit", :format => :js, "check_#{vm.id}" => "1" }
expect(controller.send(:flash_errors?)).not_to be_truthy
end

context 'displaying nested lists from summary page of container provider' do
let(:provider) { ManageIQ::Providers::ContainerManager.new }

before do
allow(controller).to receive(:javascript_redirect).and_return(true)
allow(controller).to receive(:performed?).and_return(true)
controller.instance_variable_set(:@display, display)
controller.instance_variable_set(:@_params, :pressed => press, :miq_grid_checks => item.id.to_s, :id => provider.id)
controller.instance_variable_set(:@breadcrumbs, [])
end

{
'container_image' => 'Container Images',
'container_replicator' => 'Container Replicators',
'container_node' => 'Container Nodes',
'container_group' => 'Container Pods'
}.each do |display_s, items|
context "displaying #{items}" do
let(:item) { FactoryGirl.create(display_s.to_sym) }
let(:display) { display_s.pluralize }

context 'tagging selected #{items}' do
let(:press) { "#{display_s}_tag" }

it 'calls tag method with proper model class' do
expect(controller).to receive(:tag).with(display_s.classify.safe_constantize)
controller.send(:button)
end
end

context 'managing policies of selected #{items}' do
let(:press) { "#{display_s}_protect" }

it 'calls assign_policies method with proper model class' do
expect(controller).to receive(:assign_policies).with(display_s.classify.safe_constantize)
controller.send(:button)
end
end

context 'checking compliance of selected #{items}' do
let(:press) { "#{display_s}_check_compliance" }

it 'calls check_compliance_nested method with proper model class' do
expect(controller).to receive(:check_compliance_nested).with(display_s.classify.safe_constantize)
controller.send(:button)
end
end
end
end
end
end

describe "#download_summary_pdf" do
Expand Down

0 comments on commit b00c996

Please sign in to comment.