-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11879 from vecerek/toolbar_refactoring__miq_serve…
…r_and_region Toolbar refactoring miq server and region
- Loading branch information
Showing
5 changed files
with
42 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationHelper::Button::RefreshWorkers < ApplicationHelper::Button::Basic | ||
needs :@record, :@sb | ||
|
||
def visible? | ||
@view_context.x_active_tree == :diagnostics_tree && @sb[:active_tab] == 'diagnostics_workers' | ||
end | ||
end |
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
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
31 changes: 31 additions & 0 deletions
31
spec/helpers/application_helper/buttons/refresh_workers_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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe ApplicationHelper::Button::RefreshWorkers do | ||
let(:view_context) { setup_view_context_with_sandbox({}) } | ||
let(:record) { FactoryGirl.create(:miq_server) } | ||
|
||
describe '#visible?' do | ||
context 'when x_active_tree == diagnostics_tree and active_tab != diagnostics_workers' do | ||
it 'will be skipped' do | ||
button = described_class.new(view_context, {}, {'record' => record}, {}) | ||
button.instance_variable_set(:@sb, :active_tab => 'does not matter') | ||
allow(view_context).to receive(:x_active_tree).and_return(:diagnostics_tree) | ||
expect(button.visible?).to be_falsey | ||
end | ||
end | ||
context 'when x_active_tree != diagnostics_tree and active_tab == diagnostics_workers' do | ||
it 'will be skipped' do | ||
button = described_class.new(view_context, {}, {'record' => record}, {}) | ||
button.instance_variable_set(:@sb, :active_tab => 'diagnostics_workers') | ||
allow(view_context).to receive(:x_active_tree).and_return(:does_not_matter) | ||
expect(button.visible?).to be_falsey | ||
end | ||
end | ||
context 'when x_active_tree == diagnostics_tree and active_tab == diagnostics_workers' do | ||
it 'will not be skipped' do | ||
button = described_class.new(view_context, {}, {'record' => record}, {}) | ||
button.instance_variable_set(:@sb, :active_tab => 'diagnostics_workers') | ||
allow(view_context).to receive(:x_active_tree).and_return(:diagnostics_tree) | ||
expect(button.visible?).to be_truthy | ||
end | ||
end | ||
end | ||
end |
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