Skip to content

Commit

Permalink
Spec for dialog run submit with no request created
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed Dec 14, 2016
1 parent 59b7dff commit 10fd22f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions spec/controllers/application_controller/dialog_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@

describe "#dialog_form_button_pressed" do
let(:dialog) { double("Dialog") }
let(:workflow) { FactoryGirl.build(:miq_provision_workflow) }
let(:wf) { double(:dialog => dialog) }

before do
Expand All @@ -144,10 +145,10 @@
session[:edit] = edit
end

it "redirects to requests show list after dialog is submitted" do
it "redirects to requests show list after the dialog is submitted if a request is created" do
controller.instance_variable_set(:@_params, :button => 'submit', :id => 'foo')
allow(controller).to receive(:role_allows?).and_return(true)
allow(wf).to receive(:submit_request).and_return({})
allow(wf).to receive(:submit_request).and_return(:request => workflow.make_request(nil, {}))
page = double('page')
allow(page).to receive(:<<).with(any_args)
expect(page).to receive(:redirect_to).with(:controller => "miq_request",
Expand All @@ -156,5 +157,17 @@
expect(controller).to receive(:render).with(:update).and_yield(page)
controller.send(:dialog_form_button_pressed)
end

it "stay on the current model page after the dialog is submitted if a request is not created" do
controller.instance_variable_set(:@_params, :button => 'submit', :id => 'foo')
st = FactoryGirl.create(:service_template)
controller.x_node = "xx-st st-#{st.id}"
allow(controller).to receive(:role_allows?).and_return(true)
allow(controller).to receive(:get_node_info)
allow(controller).to receive(:render)
allow(wf).to receive(:submit_request).and_return({})
expect(controller).to receive(:replace_right_cell)
controller.send(:dialog_form_button_pressed)
end
end
end

0 comments on commit 10fd22f

Please sign in to comment.