@@ -157,12 +157,20 @@ def latest_verifications_for_consumer_version_url version, base_url
157
157
"#{ base_url } /verification-results/consumer/#{ url_encode ( version . pacticipant . name ) } /version/#{ version . number } /latest"
158
158
end
159
159
160
- def latest_verification_for_pact_url pact , base_url
161
- verification_url_from_params (
162
- provider_name : pact . provider_name ,
163
- consumer_name : pact . consumer_name ,
164
- pact_version_sha : pact . pact_version_sha ,
165
- verification_number : 'latest' )
160
+ def latest_verification_for_pact_url pact , base_url , permalink = true
161
+ if permalink
162
+ verification_url_from_params (
163
+ {
164
+ provider_name : provider_name ( pact ) ,
165
+ consumer_name : consumer_name ( pact ) ,
166
+ pact_version_sha : pact . pact_version_sha ,
167
+ verification_number : 'latest'
168
+ } ,
169
+ base_url
170
+ )
171
+ else
172
+ pact_url ( base_url , pact ) + "/verification-results/latest"
173
+ end
166
174
end
167
175
168
176
def verification_triggered_webhooks_url verification , base_url = ''
@@ -276,6 +284,30 @@ def pactigration_base_url_from_params base_url, params
276
284
'consumer' , url_encode ( params [ :consumer_name ] )
277
285
] . join ( '/' )
278
286
end
287
+
288
+ def consumer_name ( thing )
289
+ if thing . respond_to? ( :consumer_name )
290
+ thing . consumer_name
291
+ elsif thing . respond_to? ( :consumer )
292
+ thing . consumer . name
293
+ elsif thing . respond_to? ( :[] )
294
+ thing [ :consumer_name ]
295
+ else
296
+ nil
297
+ end
298
+ end
299
+
300
+ def provider_name ( thing )
301
+ if thing . respond_to? ( :provider_name )
302
+ thing . provider_name
303
+ elsif thing . respond_to? ( :provider )
304
+ thing . provider . name
305
+ elsif thing . respond_to? ( :[] )
306
+ thing [ :provider_name ]
307
+ else
308
+ nil
309
+ end
310
+ end
279
311
end
280
312
end
281
313
end
0 commit comments