Skip to content

Commit

Permalink
Move dashboard_view to better places and fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZitaNemeckova committed Jan 24, 2017
1 parent cf02ffc commit 91a2b80
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,10 @@ def get_view_calculate_gtl_type(db_sym)
gtl_type
end

def dashboard_view
false
end

def get_view_process_search_text(view)
# Check for new search by name text entered
if params[:search] &&
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ def show_entities(display)
view_setup_helper(display, *view_setup_params[display])
end

def dashboard_view
false
end

def show
return unless init_show
session[:vm_summary_cool] = (settings(:views, :vm_summary_cool).to_s == "summary")
Expand Down
9 changes: 1 addition & 8 deletions app/controllers/ems_container_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class EmsContainerController < ApplicationController
include EmsCommon # common methods for EmsInfra/Cloud/Container controllers
include Mixins::EmsCommonAngular
include Mixins::GenericSessionMixin
include Mixins::DashboardViewMixin

before_action :check_privileges
before_action :get_session_data
Expand All @@ -18,14 +19,6 @@ def self.table_name
@table_name ||= "ems_container"
end

def dashboard_view
if @sb[:summary_mode].present?
@sb[:summary_mode] == 'dashboard'
else
current_user[:settings][:views][:summary_mode] == 'dashboard'
end
end

def show_list
process_show_list(:gtl_dbname => 'emscontainer')
end
Expand Down
9 changes: 1 addition & 8 deletions app/controllers/ems_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class EmsInfraController < ApplicationController
include Mixins::GenericShowMixin
include EmsCommon # common methods for EmsInfra/Cloud controllers
include Mixins::EmsCommonAngular
include Mixins::DashboardViewMixin

before_action :check_privileges
before_action :get_session_data
Expand All @@ -25,14 +26,6 @@ def new_ems_path
new_ems_infra_path
end

def dashboard_view
if @sb[:summary_mode].present?
@sb[:summary_mode] == 'dashboard'
else
current_user[:settings][:views][:summary_mode] == 'dashboard'
end
end

def index
redirect_to :action => 'show_list'
end
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/mixins/dashboard_view_mixin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Mixins
module DashboardViewMixin
def dashboard_view
if @sb[:summary_mode].present?
@sb[:summary_mode] == 'dashboard'
else
(@settings.fetch_path(:views, :summary_mode) || "dashboard") == 'dashboard'
end
end
end
end
4 changes: 1 addition & 3 deletions spec/controllers/ems_container_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
context "render" do
subject { get :show, :params => { :id => @container.id } }
render_views
it { is_expected.to render_template('shared/views/ems_common/show') }

it do
is_expected.to have_http_status 200
is_expected.to render_template(:partial => "layouts/listnav/_ems_container")
is_expected.to render_template(:partial => 'ems_container/_show_dashboard')
end

it "renders topology view" do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/ems_infra_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@

it do
is_expected.to have_http_status 200
is_expected.to render_template(:partial => "layouts/listnav/_ems_infra")
is_expected.not_to render_template(:partial => "layouts/listnav/_ems_infra")
end
end

Expand Down Expand Up @@ -413,7 +413,7 @@
breadcrumbs = controller.instance_variable_get(:@breadcrumbs)
expect(breadcrumbs).to eq([{:name => "Infrastructure Providers",
:url => "/ems_infra/show_list?page=&refresh=y"},
{:name => "#{ems.name} (Summary)",
{:name => "#{ems.name} (Dashboard)",
:url => "/ems_infra/#{ems.id}"}])
end
end
Expand Down

0 comments on commit 91a2b80

Please sign in to comment.