forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed to enable the download buttons on Utilization Report tab
- Loading branch information
Showing
2 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 45 additions & 16 deletions
61
spec/helpers/application_helper/buttons/utilization_download_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |