<commit_before>shared_examples :network_port_controller_spec do |providers|
  include CompressedIds
  render_views
  before :each do
    stub_user(:features => :all)
    setup_zone
  end

  providers.each do |t|
    context "for #{t}" do
      before :each do
        @network_port = FactoryGirl.create("network_port_#{t}".to_sym, :name => "Network Port")
      end

      describe "#show_list" do
        it "renders index" do
          get :index
          expect(response.status).to eq(302)
          expect(response).to redirect_to(:action => 'show_list')
        end

        it "renders show_list" do
          # TODO(lsmola) figure out why I have to mock pdf available here, but not in other Manager's lists
          allow(PdfGenerator).to receive_messages(:available? => false)
          session[:settings] = {:default_search => 'foo',
                                :views          => {},
                                :perpage        => {:list => 10}}
          get :show_list
          expect(response.status).to eq(200)
          expect(response.body).to_not be_empty
        end
      end

      describe "#show" do
        it "renders show screen" do
          get :show, :params => {:id => @network_port.id}
          expect(response.status).to eq(200)
          expect(response.body).to_not be_empty
          expect(assigns(:breadcrumbs)).to eq([{:name => "network_ports",
                                                :url  => "/network_port/show_list?page=&refresh=y"},
                                               {:name => "Network Port (Summary)",
                                                :url  => "/network_port/show/#{@network_port.id}"}])

          is_expected.to render_template(:partial => "layouts/listnav/_network_port")
        end
      end
<commit_msg>Add network_port specs for nested lists<commit_after>require_relative 'shared_network_manager_context'

shared_examples :network_port_controller_spec do |providers|
  include CompressedIds
  render_views
  before :each do
    stub_user(:features => :all)
    setup_zone
  end

  providers.each do |t|
    context "for #{t}" do
      include_context :shared_network_manager_context, t

      describe "#show_list" do
        it "renders index" do
          get :index
          expect(response.status).to eq(302)
          expect(response).to redirect_to(:action => 'show_list')
        end

        it "renders show_list" do
          # TODO(lsmola) figure out why I have to mock pdf available here, but not in other Manager's lists
          allow(PdfGenerator).to receive_messages(:available? => false)
          session[:settings] = {:default_search => 'foo',
                                :views          => {},
                                :perpage        => {:list => 10}}
          get :show_list
          expect(response.status).to eq(200)
          expect(response.body).to_not be_empty
        end
      end

      describe "#show" do
        it "renders show screen" do
          get :show, :params => {:id => @network_port.id}
          expect(response.status).to eq(200)
          expect(response.body).to_not be_empty
          expect(assigns(:breadcrumbs)).to eq([{:name => "network_ports",
                                                :url  => "/network_port/show_list?page=&refresh=y"},
                                               {:name => "eth0 (Summary)",
                                                :url  => "/network_port/show/#{@network_port.id}"}])

          is_expected.to render_template(:partial => "layouts/listnav/_network_port")
        end

        it "show associated cloud_subnets" do
          assert_nested_list(@network_port, [@cloud_subnet], 'cloud_subnets', 'All Cloud Subnets')
        end

        it "show associated floating ips" do
          assert_nested_list(@network_port, [@floating_ip], 'floating_ips', 'All Floating Ips')
        end
      end

{'fraction_non_alphanumeric': 0.10843989769820972, 'fraction_numerical': 0.0058823529411764705, 'mean_word_length': 1.8863468634686347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4668902', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1044, 'n_words': 259}