Skip to content

Commit

Permalink
Fixed issues with 'Back' button on right size screen
Browse files Browse the repository at this point in the history
Multiple issues fixed with back button on non-explorer version of VM Right Size recommendations screen

- fixed a typo it should be `@record.id`
- fixed call to javascript_prologue, method does not expect argument
- added code to redirect back to previous screen when back button is pressed

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1733207
  • Loading branch information
h-kataria committed Jul 29, 2019
1 parent aa7b10b commit 3389bdd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/vm_common.rb
Expand Up @@ -514,7 +514,8 @@ def right_size(record = nil)
@rightsize = true
@in_a_form = true
if params[:button] == "back"
javascript_prologue(previous_breadcrumb_url)
javascript_prologue
javascript_redirect(previous_breadcrumb_url)
end
if !@explorer && params[:button] != "back"
drop_breadcrumb(:name => _("Right Size VM '%{name}''") % {:name => @record.name}, :url => "/vm/right_size")
Expand Down
2 changes: 1 addition & 1 deletion app/views/vm_common/_right_size.html.haml
Expand Up @@ -220,5 +220,5 @@
:alt => t,
:title => t,
:onclick => "miqAjaxButton('#{url_for_only_path(:action => "right_size",
:id => @record_id,
:id => @record.id,
:button => "back")}');")
22 changes: 22 additions & 0 deletions spec/controllers/vm_controller_spec.rb
Expand Up @@ -20,4 +20,26 @@
expect(response).to render_template('vm_common/_live_migrate')
end
end

describe "#right_size" do
let(:vm) { FactoryBot.create(:vm_vmware) }
before do
stub_user(:features => :all)
end

it "when back button is pressed, it redirects back to previous screen" do
breadcrumbs = [
{:name => "Foo", :url => "/ems_infra/show_list"},
{:name => "Bar", :url => "/ems_infra/1?display=vms"},
{:name => "Right Size", :url => "/vm/right_size"}
]
controller.instance_variable_set(:@breadcrumbs, breadcrumbs)
page = double('page')
allow(page).to receive(:<<).with(any_args)
expect(page).to receive(:redirect_to).with("/ems_infra/1?display=vms")
expect(controller).to receive(:render).with(:update).and_yield(page)
controller.params = {:id => vm.id, :button => 'back'}
controller.send(:right_size)
end
end
end

0 comments on commit 3389bdd

Please sign in to comment.