diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index 65427b50beb..ef56e5364a2 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -618,7 +618,7 @@ def process_show_list(options = {}) bc_name = breadcrumb_name(model) bc_name += " - " + session["#{self.class.session_key_prefix}_type".to_sym].titleize if session["#{self.class.session_key_prefix}_type".to_sym] bc_name += " (filtered)" if @filters && (!@filters[:tags].blank? || !@filters[:cats].blank?) - action = %w(container service vm_cloud vm_infra vm_or_template storage).include?(self.class.table_name) ? "explorer" : "show_list" + action = %w(service vm_cloud vm_infra vm_or_template storage).include?(self.class.table_name) ? "explorer" : "show_list" @breadcrumbs.clear drop_breadcrumb(:name => bc_name, :url => "/#{controller_name}/#{action}") end diff --git a/app/controllers/application_controller/policy_support.rb b/app/controllers/application_controller/policy_support.rb index a6432007829..d4ff47079e6 100644 --- a/app/controllers/application_controller/policy_support.rb +++ b/app/controllers/application_controller/policy_support.rb @@ -175,7 +175,7 @@ def assign_policies(db) end end %w(image instance vm miq_template - container_replicator container_group container_node container_image ems_container).each do |old_name| + container container_replicator container_group container_node container_image ems_container).each do |old_name| alias_method "#{old_name}_protect".to_sym, :assign_policies end diff --git a/app/controllers/container_controller.rb b/app/controllers/container_controller.rb index 3bd3642cc22..3735e16d9c3 100644 --- a/app/controllers/container_controller.rb +++ b/app/controllers/container_controller.rb @@ -6,94 +6,10 @@ class ContainerController < ApplicationController after_action :cleanup_action after_action :set_session_data - CONTAINER_X_BUTTON_ALLOWED_ACTIONS = { - 'container_tag' => :container_tag_edit, - 'container_timeline' => :show_timeline, - 'container_perf' => :show_performance - } - - def x_button - generic_x_button(CONTAINER_X_BUTTON_ALLOWED_ACTIONS) - end - - # Container show selected, redirect to proper controller - def show - identify_container(params[:id]) - node_type = TreeBuilder.get_prefix_for_model(@record.class.base_model) - redirect_to :action => 'explorer', - :controller => @record.class.base_model.to_s.underscore, - :id => "#{node_type}-#{@record.id}" - end - def show_list - redirect_to :controller => "container", - :action => "explorer" - end - - def explorer - @explorer = true - @lastaction = "explorer" - @timeline = @timeline_filter = true # need to set these to load timelines on container show screen - - # if AJAX request, replace right cell, and return - if request.xml_http_request? - replace_right_cell - return - end - - build_accordions_and_trees - - if params[:id] # If a tree node id came in, show in one of the trees - nodetype, id = params[:id].split("-") - # treebuilder initializes x_node to root first time in locals_for_render, - # need to set this here to force & activate node when link is clicked outside of explorer. - @reselect_node = self.x_node = "#{nodetype}-#{to_cid(id)}" - get_node_info(x_node) - end - - params.instance_variable_get(:@parameters).merge!(session[:exp_parms]) if session[:exp_parms] # Grab any explorer parm overrides - session.delete(:exp_parms) - @in_a_form = false - render :layout => "application" process_show_list(:where_clause => 'containers.deleted_on IS NULL') end - def identify_container(id = nil) - @container = @record = identify_record(id || params[:id]) - end - - # ST clicked on in the explorer right cell - def x_show - get_tagdata(Container.find(from_cid(params[:id]))) - identify_container(from_cid(params[:id])) - generic_x_show(x_tree(:containers_tree)) - end - - # Tree node selected in explorer - def tree_select - @explorer = true - - @lastaction = "explorer" - self.x_node = params[:id] - @nodetype, id = parse_nodetype_and_id(params[:id]) - - if x_tree[:type] == :containers_filter && TreeBuilder.get_model_for_prefix(@nodetype) != "Container" - search_id = @nodetype == "root" ? 0 : from_cid(id) - adv_search_build(vm_model_from_active_tree(x_active_tree)) - session[:edit] = @edit # Set because next method will restore @edit from session - listnav_search_selected(search_id) unless params.key?(:search_text) # Clear or set the adv search filter - if @edit[:adv_search_applied] && - MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) && - %w(reload tree_select).include?(params[:action]) - self.x_node = params[:id] - quick_search_show - return - end - end - - replace_right_cell - end - private def textual_group_list @@ -101,207 +17,5 @@ def textual_group_list end helper_method :textual_group_list - def features - [{:role => "container_accord", - :role_any => true, - :name => :containers, - :title => _("Containers")}, - - {:role => "container_filter_accord", - :role_any => true, - :name => :containers_filter, - :title => _("Filters")}, - ].map do |hsh| - ApplicationController::Feature.new_with_hash(hsh) - end - end - - def container_tag_edit - container_tag - replace_right_cell(:action => "tag") - end - - def show_performance - return if perfmenu_click? - @sb[:action] = params[:display] - identify_container(params[:id]) - @showtype = "performance" - perf_gen_init_options - @refresh_partial = "layouts/performance" - replace_right_cell(:action => "perf") - end - - def show_timeline - @showtype = "timeline" - session[:tl_record_id] = params[:id] - @record = Container.find(from_cid(params[:id])) - @timeline = @timeline_filter = true - @lastaction = "show_timeline" - tl_build_timeline # Create the timeline report - @refresh_partial = "layouts/tl_show" - if params[:refresh] - @sb[:action] = "timeline" - replace_right_cell - end - replace_right_cell(:action => 'timeline') - end - - # Get all info for the node about to be displayed - def get_node_info(treenodeid, _show_list = true) - @show_adv_search = true - @nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid)) - # resetting action that was stored during edit to determine what is being edited - @sb[:action] = nil - if x_node == "root" || TreeBuilder.get_model_for_prefix(@nodetype) == "MiqSearch" - process_show_list(:where_clause => 'containers.deleted_on IS NULL') - @right_cell_text = _("All Containers") - else - show_record(from_cid(id)) - @right_cell_text = _("%{model} \"%{name}\" (Summary)") % { - :name => @record.name, - :model => ui_lookup(:model => TreeBuilder.get_model_for_prefix(@nodetype))} - end - - if @edit && @edit.fetch_path(:adv_search_applied, :qs_exp) # If qs is active, save it in history - x_history_add_item(:id => x_node, - :qs_exp => @edit[:adv_search_applied][:qs_exp], - :text => @right_cell_text) - else - x_history_add_item(:id => treenodeid, :text => @right_cell_text) # Add to history pulldown array - end - - # After adding to history, add name filter suffix if showing a list - unless @search_text.blank? - @right_cell_text += _(" (Names with \"%{text}\")") % {:text => @search_text} - end - end - - # set partial name and cell header for edit screens - def set_right_cell_vars(action) - case action - when "tag" - partial = "layouts/tagging" - header = _("Edit Tags for Container") - action = "container_tag" - when "perf" - partial = "layouts/performance" - header = _("Capacity & Utilization data for Container \"%{container_name}\"") % {:container_name => @record.name} - action = nil - when "timeline" - partial = "layouts/tl_show" - header = _("Timelines for Container \"%{container_name}\"") % {:container_name => @record.name} - action = nil - else - action = nil - end - return partial, action, header - end - - # Replace the right cell of the explorer - def replace_right_cell(options = {}) - action, replace_trees = options.values_at(:action, :replace_trees) - @explorer = true - # Set partial name, action and cell header - partial, action_url, @right_cell_text = set_right_cell_vars(action) if action - get_node_info(x_node) if !@in_a_form && !params[:display] - replace_trees = @replace_trees if @replace_trees # get_node_info might set this - type, = parse_nodetype_and_id(x_node) - trees = {} - if replace_trees - trees[:containers] = build_containers_tree if replace_trees.include?(:containers) - end - record_showing = type && ["Container"].include?(TreeBuilder.get_model_for_prefix(type)) - if !@in_a_form && !@sb[:action] - v_tb = build_toolbar("x_gtl_view_tb") unless record_showing - c_tb = build_toolbar(center_toolbar_filename) - end - h_tb = build_toolbar("x_history_tb") unless @in_a_form - - # Build presenter to render the JS command for the tree update - presenter = ExplorerPresenter.new( - :active_tree => x_active_tree, - :right_cell_text => @right_cell_text - ) - r = proc { |opts| render_to_string(opts) } - - replace_trees_by_presenter(presenter, trees) - - if action == "tag" - presenter.update(:main_div, r[:partial => partial]) - elsif params[:display] - partial_locals = {:controller => "container", :action_url => @lastaction} - if params[:display] == "timeline" - partial = "layouts/tl_show" - elsif params[:display] == "performance" - partial = "layouts/performance" - else - partial = "layouts/x_gtl" - end - presenter[:parent_id] = @record.id # Set parent rec id for JS function miqGridSort to build URL - presenter[:parent_class] = params[:controller] # Set parent class for URL also - presenter.update(:main_div, r[:partial => partial, :locals => partial_locals]) - elsif record_showing - presenter.update(:main_div, r[:partial => "container/container_show", :locals => {:controller => "container"}]) - presenter.hide(:pc_div_1, :paging_div) - else - presenter.update(:main_div, r[:partial => "layouts/x_gtl"]) - presenter.update(:paging_div, r[:partial => "layouts/x_pagingcontrols"]) - presenter.hide(:form_buttons_div).show(:pc_div_1, :paging_div) - end - - if %w(tag).include?(action) - presenter.show(:form_buttons_div).hide(:pc_div_1, :toolbar).show(:paging_div) - locals = {:action_url => action_url} - locals[:multi_record] = true # need save/cancel buttons on edit screen even tho @record.id is not there - locals[:record_id] = @sb[:rec_id] || @edit[:object_ids] && @edit[:object_ids][0] - presenter.update(:form_buttons_div, r[:partial => "layouts/x_edit_buttons", :locals => locals]) - end - - presenter[:ajax_action] = { - :controller => request.parameters["controller"], - :action => @ajax_action, - :record_id => @record.id - } if ['performance', 'timeline'].include?(@sb[:action]) - - presenter.replace(:adv_searchbox_div, r[:partial => 'layouts/x_adv_searchbox']) - - presenter[:clear_gtl_list_grid] = @gtl_type && @gtl_type != 'list' - - presenter.reload_toolbars(:history => h_tb, :center => c_tb, :view => v_tb) - - presenter.set_visibility(h_tb.present? || c_tb.present? || v_tb.present?, :toolbar) - - presenter[:record_id] = @record.try(:id) - - # Hide/show searchbox depending on if a list is showing - presenter.set_visibility(!(@record || @in_a_form), :adv_searchbox_div) - presenter[:clear_search_toggle] = clear_search_status - - presenter[:osf_node] = x_node # Open, select, and focus on this node - - presenter.hide(:blocker_div) unless @edit && @edit[:adv_search_open] - presenter.hide(:quicksearchbox) - presenter.lock_tree(x_active_tree, @in_a_form && @edit) - - render :json => presenter.for_render - end - - # Build a Containers explorer tree - def build_containers_tree - TreeBuilderContainers.new("containers_tree", "containers", @sb) - end - - def show_record(id = nil) - @display = params[:display] || "main" unless pagination_or_gtl_request? - @lastaction = "show" - @showtype = "main" - identify_container(id) - return if record_no_longer_exists?(@record) - end - - def tagging_explorer_controller? - @explorer - end - menu_section :cnt end diff --git a/app/controllers/mixins/sandbox.rb b/app/controllers/mixins/sandbox.rb index 6a1979c3fce..3613d035594 100644 --- a/app/controllers/mixins/sandbox.rb +++ b/app/controllers/mixins/sandbox.rb @@ -121,8 +121,6 @@ def x_active_tree cb_reports configuration_scripts condition - containers - containers_filter configuration_manager_cs_filter configuration_manager_providers customization_templates diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8a9ca5db38e..0e609d28263 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -851,6 +851,7 @@ def display_adv_search? cloud_tenant cloud_volume configuration_job + container container_build container_group container_image @@ -1272,6 +1273,7 @@ def pdf_page_size_style condition configuration_job configuration_script_source + container container_build container_dashboard container_group @@ -1377,6 +1379,7 @@ def render_listnav_filename cloud_volume_backup cloud_volume_snapshot configuration_job + container container_build container_group container_image @@ -1444,6 +1447,7 @@ def render_listnav_filename cloud_volume_snapshot condition configuration_job + container container_build container_group container_image @@ -1504,6 +1508,7 @@ def show_adv_search? cloud_volume_backup cloud_volume_snapshot configuration_job + container container_build container_group container_image @@ -1601,8 +1606,6 @@ def miq_tab_content(id, active = nil, options = {}, &_block) def tree_with_advanced_search? %i(automation_manager_providers automation_manager_cs_filter - containers - containers_filter configuration_manager_cs_filter configuration_scripts configuration_manager_providers diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index e61a53198c0..28d62747c25 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -485,6 +485,7 @@ def center_toolbar_filename_classic cloud_volume_backup cloud_volume_snapshot configuration_job + container container_group container_node container_service diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index 45dd4361793..a6147645a9f 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -104,7 +104,7 @@ def container_menu_section Menu::Item.new('container_service', N_('Container Services'), 'container_service', {:feature => 'container_service_show_list'}, '/container_service'), Menu::Item.new('container_replicator', N_('Replicators'), 'container_replicator', {:feature => 'container_replicator_show_list'}, '/container_replicator'), Menu::Item.new('container_group', N_('Pods'), 'container_group', {:feature => 'container_group_show_list'}, '/container_group'), - Menu::Item.new('container', N_('Containers'), 'containers', {:feature => 'containers', :any => true}, '/container/explorer'), + Menu::Item.new('container', N_('Containers'), 'container', {:feature => 'container_show_list'}, '/container'), Menu::Item.new('container_node', N_('Container Nodes'), 'container_node', {:feature => 'container_node_show_list'}, '/container_node'), Menu::Item.new('persistent_volume', N_('Volumes'), 'persistent_volume', {:feature => 'persistent_volume_show_list', :any => true}, '/persistent_volume'), Menu::Item.new('container_build', N_('Container Builds'), 'container_build', {:feature => 'container_build_show_list'}, '/container_build'), diff --git a/app/presenters/tree_builder.rb b/app/presenters/tree_builder.rb index 67cb102e730..6935522b096 100644 --- a/app/presenters/tree_builder.rb +++ b/app/presenters/tree_builder.rb @@ -410,10 +410,6 @@ def resolve_object_lambdas(count_only, objects) :schedules => "TreeBuilderReportSchedules", :widgets => "TreeBuilderReportWidgets", - # containers explorer tree - :containers => "TreeBuilderContainers", - :containers_filter => "TreeBuilderContainersFilter", - # automate explorer tree :ae => "TreeBuilderAeClass", diff --git a/app/presenters/tree_builder_containers.rb b/app/presenters/tree_builder_containers.rb deleted file mode 100644 index fabed3c0671..00000000000 --- a/app/presenters/tree_builder_containers.rb +++ /dev/null @@ -1,46 +0,0 @@ -class TreeBuilderContainers < TreeBuilder - private - - def tree_init_options(_) - { - :leaf => "Container", - :open_all => true, - :full_ids => true - } - end - - def set_locals_for_render - locals = super - locals.merge!(:autoload => true) - end - - # level 0 - root - def root_options - { - :title => t = _("All Containers (by Pods)"), - :tooltip => t - } - end - - # level 1 - pods - def x_get_tree_roots(count_only, _options) - objects = ContainerGroup.where(:deleted_on => nil).order(:name) - list = objects.compact.map do |c| - { - :id => c.id, - :text => c.name, - :tip => c.ems_ref, - :icon => "pficon pficon-folder-close", - :cfmeNoClick => true - } - end - count_only_or_objects(count_only, list) - end - - # level 2 - containers - def x_get_tree_custom_kids(object, count_only, _options) - container_group = ContainerGroup.find(object[:id]) - objects = Rbac.filtered(container_group.containers.where(:deleted_on => nil)) if container_group - count_only_or_objects(count_only, objects, 'name') - end -end diff --git a/app/presenters/tree_builder_containers_filter.rb b/app/presenters/tree_builder_containers_filter.rb deleted file mode 100644 index f5a1682d3eb..00000000000 --- a/app/presenters/tree_builder_containers_filter.rb +++ /dev/null @@ -1,39 +0,0 @@ -class TreeBuilderContainersFilter < TreeBuilder - private - - def tree_init_options(_) - { - :leaf => "Container", - :full_ids => true - } - end - - def set_locals_for_render - locals = super - locals.merge!(:autoload => true, :allow_reselect => true) - end - - def root_options - { - :title => t = _("All Containers"), - :tooltip => t - } - end - - # Get root nodes count/array for explorer tree - def x_get_tree_roots(_count_only, _options) - [ - {:id => "global", - :text => _("Global Filters"), - :icon => "pficon pficon-folder-close", - :tip => _("Global Shared Filters"), - :cfmeNoClick => true} - ] - end - - def x_get_tree_custom_kids(object, count_only, options) - return count_only ? 0 : [] if object[:id] != "global" - objects = MiqSearch.where(:db => options[:leaf]).visible_to_all - count_only_or_objects(count_only, objects, 'description') - end -end diff --git a/app/views/configuration/_ui_2.html.haml b/app/views/configuration/_ui_2.html.haml index a9841748fef..1af81118333 100644 --- a/app/views/configuration/_ui_2.html.haml +++ b/app/views/configuration/_ui_2.html.haml @@ -39,7 +39,7 @@ #{view_name} .col-md-8 %ul.list-inline= render_view_buttons(resource, @edit[:new][:views][resource]) - - if has_any_role?(%w(ems_container_show_list container_group_show_list container_node_show_list container_route_show_list container_project_show_list container_replicator_show_list container_image_show_list container_image_registry_show_list container_service_accord containers_filter_accord containers_accord persistent_volume container_build_show_list container_template_show_list)) + - if has_any_role?(%w(ems_container_show_list container_group_show_list container_node_show_list container_route_show_list container_show_list container_project_show_list container_replicator_show_list container_image_show_list container_image_registry_show_list container_service_accord containers_filter_accord containers_accord persistent_volume container_build_show_list container_template_show_list)) %fieldset %h3 = _('Containers') @@ -48,6 +48,7 @@ :containergroup => "container_group", :containerservice => "container_service", :containerroute => "container_route", + :container => "container", :containerproject => "container_project", :containerreplicator => "container_replicator", :containerimage => "container_image", diff --git a/app/views/container/_container_show.html.haml b/app/views/container/_container_show.html.haml deleted file mode 100644 index 7aa7a5d10da..00000000000 --- a/app/views/container/_container_show.html.haml +++ /dev/null @@ -1 +0,0 @@ -= render :partial => "layouts/textual_groups_generic" diff --git a/app/views/container/_explorer.js.haml b/app/views/container/_explorer.js.haml deleted file mode 100644 index 6f88c12f708..00000000000 --- a/app/views/container/_explorer.js.haml +++ /dev/null @@ -1,2 +0,0 @@ --# Renders JS to replace the contents of the miq_policy explorer view as directed by the controller -= render :partial => "shared/explorer", :locals => {:options => options} diff --git a/app/views/container/explorer.html.haml b/app/views/container/explorer.html.haml deleted file mode 100644 index e5bc5f21830..00000000000 --- a/app/views/container/explorer.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- content_for :search do - = render(:partial => "layouts/x_adv_searchbox") - = render(:partial => 'layouts/quick_search') -#main_div - - if @showtype == "timeline" - = render(:partial => "layouts/tl_show_async") - - elsif @showtype == "performance" - = render(:partial => "layouts/performance_async") - - elsif TreeBuilder.get_model_for_prefix(@nodetype) == "Container" - -# Showing a specific Service - = render :partial => "container_show", :locals => {:controller => "container"} - - else - -# Showing a list of Containers - = render :partial => 'layouts/x_gtl' diff --git a/app/views/container/show.html.haml b/app/views/container/show.html.haml new file mode 100644 index 00000000000..6c05f83d1e2 --- /dev/null +++ b/app/views/container/show.html.haml @@ -0,0 +1,8 @@ +- if %w(container_routes container_services container_replicators container_groups container_nodes container_images container_templates).include?(@display) + = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} +- elsif @showtype == "timeline" + = render :partial => "layouts/tl_show_async" +- elsif @showtype == "performance" + = render :partial => "layouts/performance_async" +- elsif @showtype == "main" + = render :partial => "layouts/textual_groups_generic" diff --git a/app/views/container/show_list.html.haml b/app/views/container/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/container/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/layouts/listnav/_container.html.haml b/app/views/layouts/listnav/_container.html.haml new file mode 100644 index 00000000000..652d8a9f6b0 --- /dev/null +++ b/app/views/layouts/listnav/_container.html.haml @@ -0,0 +1,35 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render_quadicon(@record, :mode => :icon, :size => 72, :typ => :listnav) + + = miq_accordion_panel(_("Properties"), false, "container_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + {:title => _("Show Summary")}) + + - if @record.has_perf_data? + %li + = link_to(_('Capacity & Utilization'), + {:action => 'show', :id => @record, :display => 'performance'}, + {:title => _("Show Capacity & Utilization")}) + - else + %li.disabled + = link_to(_('Capacity & Utilization'), "#") + + - if @record.has_events? || @record.has_events?(:policy_events) + %li + = link_to('Timelines', + {:action => 'show', :display => 'timeline', :id => @record}, + {:title => _("Show Timelines")}) + - else + %li.disabled + = link_to(_('Timelines'), "#") + + = miq_accordion_panel(_("Relationships"), false, "container_rel") do + %ul.nav.nav-pills.nav-stacked + = single_relationship_link(@record, :ems_container, "ext_management_system") + - %w(container_project container_group container_node container_image).each do |ent| + = single_relationship_link(@record, ent) diff --git a/config/routes.rb b/config/routes.rb index 7f738257c86..fdb51d95f47 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -600,7 +600,6 @@ :get => %w( download_data download_summary_pdf - explorer perf_top_chart show tl_chooser @@ -613,15 +612,17 @@ accordion_select button container_form_field_changed - explorer + show + show_list tl_chooser wait_for_task quick_search reload tree_autoload tree_select - container_tag + tagging_edit tag_edit_form_field_changed + listnav_search_selected ) + adv_search_post + exp_post + diff --git a/spec/controllers/container_controller_spec.rb b/spec/controllers/container_controller_spec.rb index 45876f64d66..7ab8fe2832c 100644 --- a/spec/controllers/container_controller_spec.rb +++ b/spec/controllers/container_controller_spec.rb @@ -1,140 +1,67 @@ describe ContainerController do + render_views before(:each) do - server = EvmSpecHelper.local_miq_server - allow(MiqServer).to receive(:my_server).and_return(server) - allow(MiqServer).to receive(:my_zone).and_return("default") stub_user(:features => :all) end - render_views - - context "#tags_edit" do - let!(:user) { stub_user(:features => :all) } - before(:each) do - EvmSpecHelper.create_guid_miq_server_zone - @ct = FactoryGirl.create(:container, :name => "container-01") - allow(@ct).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags") - classification = FactoryGirl.create(:classification, :name => "department", :description => "Department") - - seed_session_trees('container', :containers_tree, "cnt_#{controller.to_cid(@ct.id)}") - @tag1 = FactoryGirl.create(:classification_tag, - :name => "tag1", - :parent => classification) - @tag2 = FactoryGirl.create(:classification_tag, - :name => "tag2", - :parent => classification) - allow(Classification).to receive(:find_assigned_entries).with(@ct).and_return([@tag1, @tag2]) - session[:tag_db] = "Container" - edit = { - :key => "Container_edit_tags__#{@ct.id}", - :tagging => "Container", - :object_ids => [@ct.id], - :current => {:assignments => []}, - :new => {:assignments => [@tag1.id, @tag2.id]} - } - session[:edit] = edit - end - - after(:each) do - expect(response.status).to eq(200) - end - - it "builds tagging screen" do - controller.instance_variable_set(:@explorer, true) - post :x_button, :params => { :pressed => "container_tag", :format => :js, :id => @ct.id } - expect(assigns(:flash_array)).to be_nil - expect(assigns(:entries)).not_to be_nil - end - - it "cancels tags edit" do - session[:breadcrumbs] = [{:url => "container/explorer}"}, 'placeholder'] - post :container_tag, :params => { :button => "cancel", :id => @ct.id } - expect(assigns(:flash_array).first[:message]).to include("was cancelled") - expect(assigns(:edit)).to be_nil - end + it "renders index" do + get :index + expect(response.status).to eq(302) + expect(response).to redirect_to(:action => 'show_list') + end - it "save tags" do - session[:breadcrumbs] = [{:url => "container/explorer"}, 'placeholder'] - post :container_tag, :params => { :button => "save", :format => :js, :id => @ct.id } - expect(assigns(:flash_array).first[:message]).to include("Tag edits were successfully saved") - expect(assigns(:edit)).to be_nil - end + it "renders show screen" do + EvmSpecHelper.create_guid_miq_server_zone + ems = FactoryGirl.create(:ems_kubernetes) + container_project = ContainerProject.create(:ext_management_system => ems) + container_group = ContainerGroup.create(:ext_management_system => ems, + :container_project => container_project, + :name => "Test Group") + container = FactoryGirl.create(:container, :container_group => container_group, :name => "Test Container") + + get :show, :params => { :id => container.id } + expect(response.status).to eq(200) + expect(response.body).to_not be_empty + expect(assigns(:breadcrumbs)).to eq([{:name => "Containers", + :url => "/container/show_list?page=&refresh=y"}, + {:name => "Test Container (Summary)", + :url => "/container/show/#{container.id}"}]) end - context "#x_button" do - before(:each) do + describe "#show" do + before do + EvmSpecHelper.create_guid_miq_server_zone + login_as FactoryGirl.create(:user) + ems = FactoryGirl.create(:ems_kubernetes) container_project = ContainerProject.create(:ext_management_system => ems) container_group = ContainerGroup.create(:ext_management_system => ems, - :container_project => container_project) - @ct = FactoryGirl.create(:container, - :name => "container-01", - :container_group => container_group, - :ext_management_system => ems - ) - allow(controller).to receive(:x_node).and_return("cnt_#{controller.to_cid(@ct.id)}") - controller.instance_variable_set(:@record, @ct) - FactoryGirl.create(:ems_event, :container_id => @ct.id) + :container_project => container_project, + :name => "Test Group") + @container = FactoryGirl.create(:container, :container_group => container_group, :name => "Test Container") end - after(:each) do - expect(response.status).to eq(200) - end + subject { get :show, :params => { :id => @container.id } } - it "renders timeline views" do - post :x_button, :params => { - :pressed => "container_timeline", - :id => @ct.id, - :display => 'timeline' - } - expect(response).to render_template('layouts/_tl_show') - expect(response).to render_template('layouts/_tl_detail') - end + context "render" do + render_views - it "renders utilization views" do - post :x_button, :params => { - :pressed => "container_perf", - :id => @ct.id, - :display => 'performance' - } - expect(response).to render_template('layouts/_perf_options') - expect(response).to render_template('layouts/_perf_charts') + it do + is_expected.to have_http_status 200 + is_expected.to render_template(:partial => "layouts/listnav/_container") + is_expected.to render_template('shared/summary/_textual_multilabel') + end end end - let(:ems) { FactoryGirl.create(:ems_kubernetes) } - let(:container_project) { ContainerProject.create(:ext_management_system => ems) } - - let(:container_group) do - ContainerGroup.create(:ext_management_system => ems, - :container_project => container_project) - end + it "renders show_list" do + session[:settings] = {:default_search => 'foo', + :views => {:container => 'list'}, + :perpage => {:list => 10}} + EvmSpecHelper.create_guid_miq_server_zone - let(:container_definition) { ContainerDefinition.create(:name => "ruby-example") } - - let(:container) do - FactoryGirl.create(:container, - :name => "container-01", - :container_group => container_group, - :container_definition => container_definition, - :ext_management_system => ems) - end - - context "#tree_select" do - it "renders container details for container node" do - session[:settings] = {} - seed_session_trees('containers', 'containers_tree') - - post :tree_select, - :params => { - :id => "xx-10000000000001_cnt-#{container.compressed_id}", - :format => :js - } - - expect(response).to render_template('layouts/_textual_groups_generic') - expect(response).to render_template('shared/summary/_textual_tags') - expect(response).to render_template('shared/summary/_textual_multilabel') - expect(response.status).to eq(200) - end + get :show_list + expect(response.status).to eq(200) + expect(response.body).to_not be_empty end end diff --git a/spec/presenters/tree_builder_containers_spec.rb b/spec/presenters/tree_builder_containers_spec.rb deleted file mode 100644 index b7a446eebbb..00000000000 --- a/spec/presenters/tree_builder_containers_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe TreeBuilderContainers do - let(:tag) { FactoryGirl.create(:tag, :name => "/managed/department/accounting") } - let(:role) { FactoryGirl.create(:miq_user_role, :name => "EvmRole-operator") } - let(:group) { FactoryGirl.create(:miq_group, :miq_user_role => role, :description => "Group 1") } - let(:user) { FactoryGirl.create(:user, :userid => 'User 1', :miq_groups => [group]) } - - before do - MiqRegion.seed - EvmSpecHelper.local_miq_server - - @container_group = FactoryGirl.create(:container_group, :name => "Pod", :id => 42) - @tagged_container = FactoryGirl.create(:container, - :name => "Tagged Container", - :tags => [tag], - :container_group => @container_group) - @untagged_container = FactoryGirl.create(:container, - :name => "Untagged Container", - :container_group => @container_group) - login_as user - end - - describe ".new" do - def get_tree_results(tree) - tree.x_get_child_nodes("xx-42").map { |c| c[:title] } - end - - it "returns all containers" do - tree = TreeBuilderContainers.new("containers_tree", "containers", {}, true) - results = get_tree_results(tree) - expect(results).to match_array(["Untagged Container", "Tagged Container"]) - end - - it "returns tagged containers, logged user with tag filter" do - user.current_group.entitlement = Entitlement.create! - user.current_group.entitlement.set_managed_filters([tag.name]) - @tree = TreeBuilderContainers.new("containers_tree", "containers", {}, true) - results = get_tree_results(@tree) - expect(results).to match_array(["Tagged Container"]) - end - end -end