@@ -41,10 +41,16 @@ module VCAP::CloudController
41
41
end
42
42
43
43
let ( :message ) { RouteUpdateMessage . new ( body ) }
44
- let ( :route ) { Route . make }
44
+ let ( :process ) { ProcessModel . make }
45
+ let ( :route_mapping ) { RouteMappingModel . make ( app : process . app ) }
46
+ let ( :route ) { route_mapping . route }
45
47
46
48
subject { RouteUpdate . new }
47
49
describe '#update metadata' do
50
+ before do
51
+ expect ( ProcessRouteHandler ) . not_to receive ( :new )
52
+ end
53
+
48
54
context 'when the route has no existing metadata' do
49
55
context 'when no metadata is specified' do
50
56
let ( :body ) do
@@ -135,6 +141,13 @@ module VCAP::CloudController
135
141
end
136
142
137
143
describe '#update options' do
144
+ let ( :fake_route_handler ) { instance_double ( ProcessRouteHandler ) }
145
+
146
+ before do
147
+ allow ( ProcessRouteHandler ) . to receive ( :new ) . with ( process ) . and_return ( fake_route_handler )
148
+ allow ( fake_route_handler ) . to receive ( :notify_backend_of_route_update )
149
+ end
150
+
138
151
context 'when the route has no existing options' do
139
152
context 'when no options are specified' do
140
153
let ( :body ) do
@@ -147,6 +160,11 @@ module VCAP::CloudController
147
160
route . reload
148
161
expect ( route . options ) . to eq ( { } )
149
162
end
163
+
164
+ it 'does not notifies the backend' do
165
+ expect ( fake_route_handler ) . not_to receive ( :notify_backend_of_route_update )
166
+ subject . update ( route :, message :)
167
+ end
150
168
end
151
169
152
170
context 'when an option is specified' do
@@ -161,10 +179,14 @@ module VCAP::CloudController
161
179
it 'adds the route option' do
162
180
expect ( message ) . to be_valid
163
181
subject . update ( route :, message :)
164
-
165
182
route . reload
166
183
expect ( route [ :options ] ) . to eq ( '{"loadbalancing":"round-robin"}' )
167
184
end
185
+
186
+ it 'notifies the backend' do
187
+ expect ( fake_route_handler ) . to receive ( :notify_backend_of_route_update )
188
+ subject . update ( route :, message :)
189
+ end
168
190
end
169
191
end
170
192
@@ -184,6 +206,11 @@ module VCAP::CloudController
184
206
route . reload
185
207
expect ( route . options ) . to include ( { 'loadbalancing' => 'round-robin' } )
186
208
end
209
+
210
+ it 'does not notifies the backend' do
211
+ expect ( fake_route_handler ) . not_to receive ( :notify_backend_of_route_update )
212
+ subject . update ( route :, message :)
213
+ end
187
214
end
188
215
189
216
context 'when an option is specified' do
@@ -199,9 +226,13 @@ module VCAP::CloudController
199
226
expect ( message ) . to be_valid
200
227
subject . update ( route :, message :)
201
228
route . reload
202
-
203
229
expect ( route . options ) . to include ( { 'loadbalancing' => 'least-connection' } )
204
230
end
231
+
232
+ it 'notifies the backend' do
233
+ expect ( fake_route_handler ) . to receive ( :notify_backend_of_route_update )
234
+ subject . update ( route :, message :)
235
+ end
205
236
end
206
237
207
238
context 'when the option value is set to null' do
@@ -219,6 +250,11 @@ module VCAP::CloudController
219
250
route . reload
220
251
expect ( route . options ) . to eq ( { } )
221
252
end
253
+
254
+ it 'notifies the backend' do
255
+ expect ( fake_route_handler ) . to receive ( :notify_backend_of_route_update )
256
+ subject . update ( route :, message :)
257
+ end
222
258
end
223
259
end
224
260
end
0 commit comments