<commit_before>require "spec_helper"

describe EmsCloudHelper do
  before do
    controller.send(:extend, EmsCloudHelper)
    self.class.send(:include, EmsCloudHelper)
  end

  context "textual_instances" do
    def role_allows(_)
      true
    end

    it "sets restful path for instances in summary for restful controllers" do
      controller.stub(:restful?).and_return(true)
      controller.stub(:controller_name).and_return("ems_cloud")

      FactoryGirl.create(:ems_openstack, :zone => Zone.seed)
      FactoryGirl.create(:vm_openstack)
      @ems = ManageIQ::Providers::Openstack::CloudManager.first
      vms = ManageIQ::Providers::Openstack::CloudManager::Vm.first
      vms.update_attributes(:ems_id => @ems.id)
      result = textual_instances
      expect(result[:link]).to eq("/ems_cloud/#{@ems.id}?display=instances")
    end
  end

  context "textual_images" do
    def role_allows(_)
      true
    end

    it "sets restful path for images in summary for restful controllers" do
      controller.stub(:restful?).and_return(true)
      controller.stub(:controller_name).and_return("ems_cloud")
      FactoryGirl.create(:ems_openstack, :zone => Zone.seed)
      FactoryGirl.create(:template_cloud)
      @ems = ManageIQ::Providers::Openstack::CloudManager.first
      template = MiqTemplate.first
      template.update_attributes(:ems_id => @ems.id)
      result = textual_images
      expect(result[:link]).to eq("/ems_cloud/#{@ems.id}?display=images")
    end
  end
end<commit_msg>Define role_allows once<commit_after>require "spec_helper"

describe EmsCloudHelper do
  def role_allows(_)
    true
  end

  before do
    controller.send(:extend, EmsCloudHelper)
    self.class.send(:include, EmsCloudHelper)
  end

  context "textual_instances" do
    it "sets restful path for instances in summary for restful controllers" do
      controller.stub(:restful?).and_return(true)
      controller.stub(:controller_name).and_return("ems_cloud")

      FactoryGirl.create(:ems_openstack, :zone => Zone.seed)
      FactoryGirl.create(:vm_openstack)
      @ems = ManageIQ::Providers::Openstack::CloudManager.first
      vms = ManageIQ::Providers::Openstack::CloudManager::Vm.first
      vms.update_attributes(:ems_id => @ems.id)
      result = textual_instances
      expect(result[:link]).to eq("/ems_cloud/#{@ems.id}?display=instances")
    end
  end

  context "textual_images" do
    it "sets restful path for images in summary for restful controllers" do
      controller.stub(:restful?).and_return(true)
      controller.stub(:controller_name).and_return("ems_cloud")
      FactoryGirl.create(:ems_openstack, :zone => Zone.seed)
      FactoryGirl.create(:template_cloud)
      @ems = ManageIQ::Providers::Openstack::CloudManager.first
      template = MiqTemplate.first
      template.update_attributes(:ems_id => @ems.id)
      result = textual_images
      expect(result[:link]).to eq("/ems_cloud/#{@ems.id}?display=images")
    end
  end
end
{'fraction_non_alphanumeric': 0.11677354033074587, 'fraction_numerical': 0.0, 'mean_word_length': 4.006756756756757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2886904', 'n_tokens_mistral': 943, 'n_tokens_neox': 904, 'n_words': 171}