<commit_before>describe EmsBlockStorageController do
  include_examples :shared_examples_for_ems_block_storage_controller, %w(openstack)

  describe "#check_generic_rbac" do
    let(:feature) { MiqProductFeature.find_all_by_identifier(%w(cloud_subnet_new)) }
    let(:role)    { FactoryGirl.create(:miq_user_role, :miq_product_features => feature) }
    let(:group)   { FactoryGirl.create(:miq_group, :miq_user_role => role) }
    let(:user)    { FactoryGirl.create(:user, :miq_groups => [group]) }

    before do
      EvmSpecHelper.create_guid_miq_server_zone
      EvmSpecHelper.seed_specific_product_features(%w(cloud_subnet_new ems_block_storage_show_list))

      allow(User).to receive(:current_user).and_return(user)
      allow(Rbac).to receive(:role_allows?).and_call_original
      login_as user
    end

    it "denies access because user don't have needed role feature" do
      controller.action_name = 'report_data'
      expect(controller.send(:check_generic_rbac)).to be_falsey
    end

    context 'user has needed role feature' do
      let(:feature) { MiqProductFeature.find_all_by_identifier(%w(ems_block_storage_show_list)) }

      it "allows access" do
        controller.action_name = 'report_data'
        expect(controller.send(:check_generic_rbac)).to be_truthy
      end
    end
  end<commit_msg>Add spec test to check rendered toolbar on Block Storage Managers page<commit_after>describe EmsBlockStorageController do
  include_examples :shared_examples_for_ems_block_storage_controller, %w(openstack)

  describe "#check_generic_rbac" do
    let(:feature) { MiqProductFeature.find_all_by_identifier(%w(cloud_subnet_new)) }
    let(:role)    { FactoryGirl.create(:miq_user_role, :miq_product_features => feature) }
    let(:group)   { FactoryGirl.create(:miq_group, :miq_user_role => role) }
    let(:user)    { FactoryGirl.create(:user, :miq_groups => [group]) }

    before do
      EvmSpecHelper.create_guid_miq_server_zone
      EvmSpecHelper.seed_specific_product_features(%w(cloud_subnet_new ems_block_storage_show_list))

      allow(User).to receive(:current_user).and_return(user)
      allow(Rbac).to receive(:role_allows?).and_call_original
      login_as user
    end

    it "denies access because user don't have needed role feature" do
      controller.action_name = 'report_data'
      expect(controller.send(:check_generic_rbac)).to be_falsey
    end

    context 'user has needed role feature' do
      let(:feature) { MiqProductFeature.find_all_by_identifier(%w(ems_block_storage_show_list)) }

      it "allows access" do
        controller.action_name = 'report_data'
        expect(controller.send(:check_generic_rbac)).to be_truthy
      end
    end
  end

  describe '#show_list' do
    render_views

    it 'renders the Block Storage Managers Toolbar' do
      expect(ApplicationHelper::Toolbar::GtlView).to receive(:definition)
      post :show_list
    end
  end
{'fraction_non_alphanumeric': 0.09252912954078135, 'fraction_numerical': 0.0, 'mean_word_length': 4.435754189944134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7655465', 'n_tokens_mistral': 946, 'n_tokens_neox': 909, 'n_words': 170}