Skip to content

Commit

Permalink
Merge pull request #6542 from hstastna/Cancel_after_applying_changes_…
Browse files Browse the repository at this point in the history
…Compare

Display Cancel after applying changes in non-explorer Compare screen
  • Loading branch information
himdel committed Jan 6, 2020
2 parents e33a284 + 586577c commit 2d780ba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller/compare.rb
Expand Up @@ -420,7 +420,7 @@ def drift_same
# AJAX driven routine to check for changes in ANY field on the form
def sections_field_changed
@keep_compare = true
@explorer = %w[VMs Templates].include?(session[:db_title])
@explorer = %w[VMs Templates].include?(session[:db_title]) && @display.nil?
if params[:check] == "drift"
section_checked(:drift)
elsif params[:check] == "compare_miq"
Expand Down
28 changes: 28 additions & 0 deletions spec/controllers/application_controller/compare_spec.rb
Expand Up @@ -166,6 +166,34 @@ def init_fields_and_results(clusters)
controller.send(:sections_field_changed)
expect(session[:selected_sections]).to eq(["_model_", "hardware"])
end

context 'changes in Comparison Sections' do
before do
allow(controller).to receive(:render)
allow(controller).to receive(:session).and_return(:db_title => 'VMs')
controller.instance_variable_set(:@display, 'instances')
controller.params = {:check => 'true'}
end

it 'sets @explorer to false' do
controller.send(:sections_field_changed)
expect(controller.instance_variable_get(:@explorer)).to be(false)
end

it 'calls set_checked_sections according to the params' do
expect(controller).to receive(:set_checked_sections)
controller.send(:sections_field_changed)
end

context 'explorer screen' do
before { controller.instance_variable_set(:@display, nil) }

it 'sets @explorer to true' do
controller.send(:sections_field_changed)
expect(controller.instance_variable_get(:@explorer)).to be(true)
end
end
end
end

context 'drifts' do
Expand Down

0 comments on commit 2d780ba

Please sign in to comment.