Skip to content

Commit 61493be

Browse files
committed
Verify call to notify_backend_of_route_update in route.update
1 parent 52f18bf commit 61493be

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

spec/unit/actions/route_update_spec.rb

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ module VCAP::CloudController
4141
end
4242

4343
let(:message) { RouteUpdateMessage.new(body) }
44-
let(:route) { Route.make }
44+
let(:space) { Space.make }
45+
let(:route) { Route.make(space:) }
4546

4647
subject { RouteUpdate.new }
4748
describe '#update metadata' do
@@ -143,6 +144,13 @@ module VCAP::CloudController
143144

144145
it 'adds no options' do
145146
expect(message).to be_valid
147+
148+
fake_route_handler = instance_double(ProcessRouteHandler)
149+
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
150+
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
151+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
152+
expect(fake_route_handler).to receive(:notify_backend_of_route_update)
153+
146154
subject.update(route:, message:)
147155
route.reload
148156
expect(route.options).to eq({})
@@ -160,8 +168,14 @@ module VCAP::CloudController
160168

161169
it 'adds the route option' do
162170
expect(message).to be_valid
163-
subject.update(route:, message:)
164171

172+
fake_route_handler = instance_double(ProcessRouteHandler)
173+
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
174+
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
175+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
176+
expect(fake_route_handler).to receive(:notify_backend_of_route_update)
177+
178+
subject.update(route:, message:)
165179
route.reload
166180
expect(route[:options]).to eq('{"loadbalancing":"round-robin"}')
167181
end
@@ -180,6 +194,13 @@ module VCAP::CloudController
180194

181195
it 'modifies nothing' do
182196
expect(message).to be_valid
197+
198+
fake_route_handler = instance_double(ProcessRouteHandler)
199+
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
200+
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
201+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
202+
expect(fake_route_handler).to receive(:notify_backend_of_route_update)
203+
183204
subject.update(route:, message:)
184205
route.reload
185206
expect(route.options).to include({ 'loadbalancing' => 'round-robin' })
@@ -197,6 +218,13 @@ module VCAP::CloudController
197218

198219
it 'updates the option' do
199220
expect(message).to be_valid
221+
222+
fake_route_handler = instance_double(ProcessRouteHandler)
223+
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
224+
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
225+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
226+
expect(fake_route_handler).to receive(:notify_backend_of_route_update)
227+
200228
subject.update(route:, message:)
201229
route.reload
202230

@@ -215,6 +243,13 @@ module VCAP::CloudController
215243

216244
it 'removes this option' do
217245
expect(message).to be_valid
246+
247+
fake_route_handler = instance_double(ProcessRouteHandler)
248+
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
249+
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
250+
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
251+
expect(fake_route_handler).to receive(:notify_backend_of_route_update)
252+
218253
subject.update(route:, message:)
219254
route.reload
220255
expect(route.options).to eq({})

0 commit comments

Comments
 (0)