Skip to content

Commit 508fd9e

Browse files
committed
Assert redirect in a rails 7.1 friendly way
In rails 7.1, the response.body in the redirect is an empty string.
1 parent d80ced6 commit 508fd9e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spec/controllers/ems_cloud_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
expect(ems).to receive(:sync_users_queue)
169169
post :sync_users, :params => {:id => ems.id, :sync => "", :admin_role => 1, :member_role => 2}
170170
expect(session[:flash_msgs]).to match [a_hash_including(:message => "Sync users queued.", :level => :success)]
171-
expect(response.body).to include("redirected")
172-
expect(response.body).to include("ems_cloud/#{ems.id}")
171+
expect(response.status).to eq(302)
172+
assert_redirected_to(controller.ems_cloud_path(ems.id))
173173
end
174174

175175
it "returns error if admin role is not selected" do

spec/controllers/ems_infra_controller_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@
206206
post :scaling, :params => { :id => @ems.id, :scale => "", :orchestration_stack_id => @orchestration_stack.id,
207207
@orchestration_stack_parameter_compute.name => 2 }
208208
expect(controller.send(:flash_errors?)).to be_falsey
209-
expect(response.body).to include("redirected")
210-
expect(response.body).to include("ems_infra")
209+
expect(response.status).to eq(302)
210+
assert_redirected_to(controller.ems_infra_path(@ems.id))
211211
expect(session[:flash_msgs]).to match [a_hash_including(:message => "Scaling compute-1::count from 1 to 2 ", :level => :success)]
212212
end
213213

@@ -266,8 +266,8 @@
266266
post :scaledown, :params => {:id => @ems.id, :scaledown => "",
267267
:orchestration_stack_id => @orchestration_stack.id, :host_ids => [@host2.id]}
268268
expect(controller.send(:flash_errors?)).to be_falsey
269-
expect(response.body).to include("redirected")
270-
expect(response.body).to include("ems_infra")
269+
expect(response.status).to eq(302)
270+
assert_redirected_to(controller.ems_infra_path(@ems.id))
271271
expect(session[:flash_msgs]).to match [a_hash_including(:message => " Scaling down to 1 compute nodes", :level => :success)]
272272
end
273273

@@ -299,8 +299,8 @@
299299
.to receive(:register_and_configure_nodes).and_return("SUCCESS")
300300
post :register_nodes, :params => {:id => @ems.id, :nodes_json => @nodes_example, :register => 1}
301301
expect(controller.send(:flash_errors?)).to be_falsey
302-
expect(response.body).to include("redirected")
303-
expect(response.body).to include("ems_infra")
302+
expect(response.status).to eq(302)
303+
assert_redirected_to(%r(#{controller.ems_infra_path(@ems.id)}))
304304
end
305305

306306
it "when failure expected, workflow service not reachable" do

0 commit comments

Comments
 (0)