Skip to content

Commit

Permalink
Merge pull request #5878 from h-kataria/vm_right_size_back_button_fix
Browse files Browse the repository at this point in the history
Fixed issues with 'Back' button on right size screen

(cherry picked from commit a459a48)

https://bugzilla.redhat.com/show_bug.cgi?id=1733207
  • Loading branch information
mzazrivec authored and simaishi committed Jul 30, 2019
1 parent 51b9763 commit 110c395
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 110c395

Please sign in to comment.