Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed to enable the download buttons on Utilization Report tab #4934

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def disabled?
return false if @view_context.x_active_tree.nil? &&
@sb.fetch_path(:planning, :rpt) && !@sb[:rpt].table.data.empty?

# b) we are in the "Utilization" and have trend report and summary
return false if @sb.fetch_path(:util, :trend_rpt) && @sb.fetch_path(:util, :summary)
# b) we are in the "Utilization" and have trend report
return false if @layout == 'miq_capacity_utilization' && @sb[:active_tab] == 'report' && !@sb.fetch_path(:trend_rpt).table.data.empty?

# c) we are in the "Bottlenecks" on 'Report' tab and have report data available
return false if @layout == 'miq_capacity_bottlenecks' && @sb[:active_tab] == 'report' && !@sb[:report].table.data.empty?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
describe ApplicationHelper::Button::UtilizationDownload do
let(:view_context) { setup_view_context_with_sandbox({}) }
let(:report) { FactoryGirl.create(:miq_report, :miq_report_results => []) }
let(:button) { described_class.new(view_context, {}, {'layout' => 'miq_capacity_bottlenecks'}, {}) }
let!(:button) { described_class.new(view_context, {}, {'layout' => 'miq_capacity_bottlenecks'}, {}) }

before do
button.instance_variable_set(:@sb, :active_tab => "report", :report => report)
allow(view_context).to receive(:x_active_tree).and_return(:bottlenecks_tree)
end
context "Bottlenecks explorer" do
before do
button.instance_variable_set(:@sb, :active_tab => "report", :report => report)
allow(view_context).to receive(:x_active_tree).and_return(:bottlenecks_tree)
end

context '#disabled?' do
it 'when report tab has no data available' do
report.table = OpenStruct.new(:data => [])
expect(button.disabled?).to be_truthy
end

it 'when report tab has data' do
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_falsey
end

context '#disabled?' do
it 'when report tab has no data available' do
report.table = OpenStruct.new(:data => [])
expect(button.disabled?).to be_truthy
it 'when on summary tab' do
button.instance_variable_set(:@sb, :active_tab => "summary", :report => report)
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_truthy
end
end
end

context "Utilization explorer" do
let(:button) { described_class.new(view_context, {}, {'layout' => 'miq_capacity_utilization'}, {}) }

it 'when report tab has data' do
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_falsey
before do
button.instance_variable_set(:@sb, :active_tab => "report", :trend_rpt => report)
allow(view_context).to receive(:x_active_tree).and_return(:utilization_tree)
end

it 'when on summary tab' do
button.instance_variable_set(:@sb, :active_tab => "summary", :report => report)
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_truthy
context '#disabled?' do
it 'when report tab has no data available' do
report.table = OpenStruct.new(:data => [])
expect(button.disabled?).to be_truthy
end

it 'when report tab has data' do
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_falsey
end

it 'when on summary tab' do
button.instance_variable_set(:@sb, :active_tab => "summary", :trend_rpt => report)
report.table = OpenStruct.new(:data => [:foo => 'bar'])
expect(button.disabled?).to be_truthy
end
end
end
end