Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/actions/route_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def update(route:, message:)

route.save
MetadataUpdate.update(route, message)

route.apps.each do |process|
ProcessRouteHandler.new(process).notify_backend_of_route_update
end
end

route
Expand Down
39 changes: 37 additions & 2 deletions spec/unit/actions/route_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module VCAP::CloudController
end

let(:message) { RouteUpdateMessage.new(body) }
let(:route) { Route.make }
Comment thread
philippthun marked this conversation as resolved.
let(:space) { Space.make }
let(:route) { Route.make(space:) }

subject { RouteUpdate.new }
describe '#update metadata' do
Comment thread
philippthun marked this conversation as resolved.
Expand Down Expand Up @@ -143,6 +144,13 @@ module VCAP::CloudController

it 'adds no options' do
expect(message).to be_valid

Comment thread
philippthun marked this conversation as resolved.
Outdated
fake_route_handler = instance_double(ProcessRouteHandler)
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
expect(fake_route_handler).to receive(:notify_backend_of_route_update)

subject.update(route:, message:)
route.reload
expect(route.options).to eq({})
Expand All @@ -160,8 +168,14 @@ module VCAP::CloudController

it 'adds the route option' do
expect(message).to be_valid
subject.update(route:, message:)

fake_route_handler = instance_double(ProcessRouteHandler)
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
expect(fake_route_handler).to receive(:notify_backend_of_route_update)

subject.update(route:, message:)
route.reload
expect(route[:options]).to eq('{"loadbalancing":"round-robin"}')
end
Expand All @@ -180,6 +194,13 @@ module VCAP::CloudController

it 'modifies nothing' do
expect(message).to be_valid

fake_route_handler = instance_double(ProcessRouteHandler)
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
expect(fake_route_handler).to receive(:notify_backend_of_route_update)

subject.update(route:, message:)
route.reload
expect(route.options).to include({ 'loadbalancing' => 'round-robin' })
Expand All @@ -197,6 +218,13 @@ module VCAP::CloudController

it 'updates the option' do
expect(message).to be_valid

fake_route_handler = instance_double(ProcessRouteHandler)
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
expect(fake_route_handler).to receive(:notify_backend_of_route_update)

subject.update(route:, message:)
route.reload

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

it 'removes this option' do
expect(message).to be_valid

fake_route_handler = instance_double(ProcessRouteHandler)
process = ProcessModelFactory.make(space: space, state: 'STARTED', diego: false)
RouteMappingModel.make(app: process.app, route: route, process_type: process.type)
allow(ProcessRouteHandler).to receive(:new).with(process).and_return(fake_route_handler)
expect(fake_route_handler).to receive(:notify_backend_of_route_update)

subject.update(route:, message:)
route.reload
expect(route.options).to eq({})
Expand Down