Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues with 'Back' button on right size screen #5878

Merged
merged 1 commit into from Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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