pact_broker 2.77.0 → 2.80.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (891) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +1 -0
  3. data/.github/workflows/test.yml +37 -11
  4. data/.rubocop.yml +37 -879
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +102 -0
  7. data/DEVELOPER_DOCUMENTATION.md +13 -0
  8. data/DEVELOPER_SETUP.md +6 -0
  9. data/Dockerfile +1 -1
  10. data/Gemfile +30 -28
  11. data/Rakefile +8 -6
  12. data/config.ru +11 -11
  13. data/config/boot.rb +6 -6
  14. data/db/ddl_statements/latest_pact_consumer_version_orders.rb +1 -1
  15. data/db/ddl_statements/latest_pact_publications_by_consumer_versions.rb +2 -2
  16. data/db/migrations/000001_create_pacticipant_table.rb +1 -1
  17. data/db/migrations/000002_create_versions_table.rb +1 -1
  18. data/db/migrations/000003_create_pacts_table.rb +1 -1
  19. data/db/migrations/000004_create_tags_table.rb +1 -1
  20. data/db/migrations/000007_increase_json_content_length.rb +1 -1
  21. data/db/migrations/000012_create_webhooks_table.rb +6 -6
  22. data/db/migrations/000015_create_pact_version_content.rb +4 -4
  23. data/db/migrations/000016_add_pact_content_foreign_key_to_pacts.rb +3 -3
  24. data/db/migrations/000017_migrate_json_content_to_pact_version_content_table.rb +2 -2
  25. data/db/migrations/000018_drop_json_content_column_from_pacts.rb +2 -2
  26. data/db/migrations/000019_make_pact_version_content_sha_not_nullable.rb +2 -2
  27. data/db/migrations/000020_add_pact_version_content_sha_to_all_pacts_view.rb +2 -2
  28. data/db/migrations/000021_recreate_latest_pacts_view.rb +2 -2
  29. data/db/migrations/000023_create_pact_versions_table.rb +3 -3
  30. data/db/migrations/000026_create_pact_publications.rb +3 -3
  31. data/db/migrations/000031_create_verifications.rb +1 -1
  32. data/db/migrations/000033_create_config_table.rb +3 -3
  33. data/db/migrations/000034_create_index_on_consumer_version_order.rb +3 -3
  34. data/db/migrations/000035_create_index_on_names.rb +2 -2
  35. data/db/migrations/000036_create_webhook_execution.rb +2 -2
  36. data/db/migrations/000037_create_labels_table.rb +1 -1
  37. data/db/migrations/000038_create_triggered_webhooks_table.rb +3 -3
  38. data/db/migrations/000041_migrate_execution_data.rb +3 -3
  39. data/db/migrations/000043_add_provider_version_to_verification.rb +1 -1
  40. data/db/migrations/000044_populate_verifications_provider_version_id.rb +9 -9
  41. data/db/migrations/20171112_add_test_results.rb +1 -1
  42. data/db/migrations/20171117_create_webhook_events.rb +3 -3
  43. data/db/migrations/20171118_create_webhook_events.rb +2 -2
  44. data/db/migrations/20180108_create_certificates_table.rb +3 -3
  45. data/db/migrations/20180109_migrate_trigger_type.rb +2 -2
  46. data/db/migrations/20180119_update_latest_triggered_webhooks.rb +1 -1
  47. data/db/migrations/20180123_create_tags_with_latest_flag.rb +1 -1
  48. data/db/migrations/20180130_create_materialized_matrix.rb +4 -4
  49. data/db/migrations/20180131_create_materialized_latest_matrix.rb +4 -4
  50. data/db/migrations/20180202_create_materialized_head_matrix.rb +4 -4
  51. data/db/migrations/20180205_drop_materialized_latest_matrix.rb +4 -4
  52. data/db/migrations/20180210_fix_latest_matrix_for_cv_and_pv_again.rb +2 -2
  53. data/db/migrations/20180311_optimise_head_matrix.rb +2 -3
  54. data/db/migrations/20180523_create_latest_verifications_for_consumer_version_tags.rb +1 -1
  55. data/db/migrations/20180524_create_latest_verifications_for_consumer_and_provider.rb +1 -1
  56. data/db/migrations/20180613_migrate_pacticipant_ids_for_verifications.rb +1 -1
  57. data/db/migrations/20180614_update_latest_verification_ids_for_consumer_and_provider.rb +1 -1
  58. data/db/migrations/20180616_migrate_consumer_ids_for_pact_publications.rb +1 -1
  59. data/db/migrations/20180720_create_latest_pact_publication_ids.rb +1 -1
  60. data/db/migrations/20180722_recreate_views.rb +1 -1
  61. data/db/migrations/20180723_create_latest_verification_ids.rb +6 -6
  62. data/db/migrations/20180729_create_latest_verification_ids_for_provider_versions.rb +1 -1
  63. data/db/migrations/20190509_create_version_sequence.rb +1 -1
  64. data/db/migrations/20190510_set_version_sequence.rb +1 -1
  65. data/db/migrations/20190524_set_webhooks_enabled.rb +1 -1
  66. data/db/migrations/20190603_migrate_webhook_headers.rb +1 -1
  67. data/db/migrations/20191025_optimise_latest_verification_ids_for_cv_tags.rb +1 -1
  68. data/db/migrations/20191028_optimise_latest_tagged_pact_cv_orders.rb +1 -1
  69. data/db/migrations/20191030_optimise_latest_pact_publications_by_consumer_versions_.rb +1 -1
  70. data/db/migrations/20191031_optimise_latest_verification_ids_for_consumer_version_tags.rb +1 -1
  71. data/db/migrations/20191101_create_head_pact_tags.rb +1 -1
  72. data/db/migrations/20200930_update_latest_triggered_webhooks.rb +2 -2
  73. data/db/migrations/20201023_create_verification_number_sequence.rb +1 -1
  74. data/db/migrations/20201024_create_version_order_sequence.rb +1 -1
  75. data/db/migrations/20201026_update_latest_verification_ids_for_consumer_and_provider.rb +2 -2
  76. data/db/migrations/20210115_add_webhook_foreign_key_indexes.rb +1 -1
  77. data/db/migrations/20210116_add_context_to_triggered_webhook.rb +1 -1
  78. data/db/migrations/20210202_add_created_at_to_head_pact_tags.rb +2 -2
  79. data/db/migrations/20210205_add_pacticipant_id_to_tag.rb +1 -1
  80. data/db/migrations/20210206_add_index_to_tags_and_versions.rb +1 -1
  81. data/db/migrations/20210207_optimise_latest_verification_ids_for_consumer_version_tags.rb +1 -1
  82. data/db/migrations/20210208_optimise_latest_tagged_pact_cv_orders.rb +1 -1
  83. data/db/migrations/20210210_create_environments_table.rb +16 -0
  84. data/db/migrations/20210216_create_deployed_versions_table.rb +18 -0
  85. data/db/migrations/20210226_set_deployment_columns_not_null.rb +31 -0
  86. data/db/migrations/20210301_add_pacticipant_columns.rb +10 -0
  87. data/db/migrations/20210413_create_currently_deployed_version_ids_table.rb +13 -0
  88. data/db/migrations/20210415_add_target_column_to_deployed_version.rb +21 -0
  89. data/db/migrations/20210419_create_released_versions_table.rb +17 -0
  90. data/db/migrations/20210529_add_main_branch_to_pacticipant.rb +18 -0
  91. data/db/migrations/20210608_add_uuid_to_webhook.rb +14 -0
  92. data/db/migrations/20210609_set_webhook_uuid.rb +11 -0
  93. data/db/migrations/20210702_drop_unused_columns_from_deployed_versions.rb +15 -0
  94. data/db/migrations/migration_helper.rb +3 -3
  95. data/db/test/backwards_compatibility/Gemfile +11 -11
  96. data/db/test/backwards_compatibility/Rakefile +17 -17
  97. data/db/test/backwards_compatibility/config.ru +6 -6
  98. data/db/test/backwards_compatibility/spec/publish_pact_spec.rb +13 -13
  99. data/db/test/backwards_compatibility/spec/spec_helper.rb +3 -3
  100. data/db/test/backwards_compatibility/spec/support/fixture_helpers.rb +2 -2
  101. data/db/test/backwards_compatibility/spec/support/request_helpers.rb +3 -4
  102. data/db/test/change_migration_strategy/Rakefile +6 -6
  103. data/db/test/change_migration_strategy/before/Gemfile +1 -1
  104. data/docker-compose-dev-postgres.yml +9 -1
  105. data/example/Gemfile +4 -4
  106. data/example/basic_auth/Gemfile +1 -1
  107. data/example/basic_auth/config.ru +7 -7
  108. data/example/config.ru +7 -7
  109. data/issue-reproduction/Dockerfile-pact-broker +1 -1
  110. data/lib/db.rb +18 -12
  111. data/lib/pact/doc/generator.rb +3 -3
  112. data/lib/pact/doc/interaction_view_model.rb +13 -13
  113. data/lib/pact/doc/markdown/consumer_contract_renderer.rb +4 -4
  114. data/lib/pact/doc/markdown/generator.rb +6 -6
  115. data/lib/pact/doc/markdown/interaction_renderer.rb +4 -4
  116. data/lib/pact/doc/sort_interactions.rb +0 -1
  117. data/lib/pact_broker.rb +4 -4
  118. data/lib/pact_broker/api.rb +102 -78
  119. data/lib/pact_broker/api/contracts/base_contract.rb +2 -2
  120. data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +18 -1
  121. data/lib/pact_broker/api/contracts/dry_validation_workarounds.rb +3 -2
  122. data/lib/pact_broker/api/contracts/environment_schema.rb +49 -0
  123. data/lib/pact_broker/api/contracts/pacticipant_name_contract.rb +1 -1
  124. data/lib/pact_broker/api/contracts/pacticipant_name_validation.rb +2 -2
  125. data/lib/pact_broker/api/contracts/pacticipant_schema.rb +34 -0
  126. data/lib/pact_broker/api/contracts/publish_contracts_schema.rb +104 -0
  127. data/lib/pact_broker/api/contracts/put_pact_params_contract.rb +1 -1
  128. data/lib/pact_broker/api/contracts/request_validations.rb +2 -2
  129. data/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb +70 -15
  130. data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +3 -3
  131. data/lib/pact_broker/api/contracts/verification_contract.rb +2 -2
  132. data/lib/pact_broker/api/contracts/webhook_contract.rb +10 -7
  133. data/lib/pact_broker/api/decorators/base_decorator.rb +20 -5
  134. data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +1 -1
  135. data/lib/pact_broker/api/decorators/configuration.rb +2 -2
  136. data/lib/pact_broker/api/decorators/dashboard_decorator.rb +8 -8
  137. data/lib/pact_broker/api/decorators/dashboard_text_decorator.rb +3 -3
  138. data/lib/pact_broker/api/decorators/decorator_context.rb +1 -1
  139. data/lib/pact_broker/api/decorators/decorator_context_creator.rb +1 -1
  140. data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +26 -0
  141. data/lib/pact_broker/api/decorators/deployed_versions_decorator.rb +20 -0
  142. data/lib/pact_broker/api/decorators/embedded_label_decorator.rb +2 -2
  143. data/lib/pact_broker/api/decorators/embedded_pacticipant_decorator.rb +17 -0
  144. data/lib/pact_broker/api/decorators/embedded_tag_decorator.rb +4 -4
  145. data/lib/pact_broker/api/decorators/embedded_version_decorator.rb +7 -2
  146. data/lib/pact_broker/api/decorators/environment_decorator.rb +51 -0
  147. data/lib/pact_broker/api/decorators/environments_decorator.rb +31 -0
  148. data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +2 -2
  149. data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +2 -2
  150. data/lib/pact_broker/api/decorators/integration_decorator.rb +2 -2
  151. data/lib/pact_broker/api/decorators/integrations_decorator.rb +2 -2
  152. data/lib/pact_broker/api/decorators/label_decorator.rb +5 -5
  153. data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +2 -2
  154. data/lib/pact_broker/api/decorators/matrix_decorator.rb +26 -11
  155. data/lib/pact_broker/api/decorators/matrix_text_decorator.rb +5 -5
  156. data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +6 -6
  157. data/lib/pact_broker/api/decorators/pact_decorator.rb +5 -5
  158. data/lib/pact_broker/api/decorators/pact_details_decorator.rb +2 -2
  159. data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +3 -3
  160. data/lib/pact_broker/api/decorators/pact_version_decorator.rb +3 -3
  161. data/lib/pact_broker/api/decorators/pact_versions_decorator.rb +2 -2
  162. data/lib/pact_broker/api/decorators/pact_webhooks_status_decorator.rb +6 -6
  163. data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +8 -8
  164. data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +29 -13
  165. data/lib/pact_broker/api/decorators/pagination_links.rb +2 -2
  166. data/lib/pact_broker/api/decorators/provider_pacts_decorator.rb +2 -3
  167. data/lib/pact_broker/api/decorators/publish_contract_decorator.rb +19 -0
  168. data/lib/pact_broker/api/decorators/publish_contracts_decorator.rb +21 -0
  169. data/lib/pact_broker/api/decorators/publish_contracts_results_decorator.rb +55 -0
  170. data/lib/pact_broker/api/decorators/reason_decorator.rb +30 -14
  171. data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +3 -1
  172. data/lib/pact_broker/api/decorators/released_version_decorator.rb +25 -0
  173. data/lib/pact_broker/api/decorators/released_versions_decorator.rb +20 -0
  174. data/lib/pact_broker/api/decorators/representable_pact.rb +1 -1
  175. data/lib/pact_broker/api/decorators/tag_decorator.rb +6 -6
  176. data/lib/pact_broker/api/decorators/tagged_pact_versions_decorator.rb +2 -2
  177. data/lib/pact_broker/api/decorators/timestamps.rb +2 -2
  178. data/lib/pact_broker/api/decorators/triggered_webhook_decorator.rb +8 -6
  179. data/lib/pact_broker/api/decorators/triggered_webhooks_decorator.rb +2 -2
  180. data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +4 -4
  181. data/lib/pact_broker/api/decorators/verifiable_pacts_decorator.rb +3 -3
  182. data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +16 -9
  183. data/lib/pact_broker/api/decorators/verification_decorator.rb +6 -6
  184. data/lib/pact_broker/api/decorators/verification_summary_decorator.rb +4 -4
  185. data/lib/pact_broker/api/decorators/version_decorator.rb +38 -7
  186. data/lib/pact_broker/api/decorators/versions_decorator.rb +5 -5
  187. data/lib/pact_broker/api/decorators/webhook_decorator.rb +10 -8
  188. data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +7 -7
  189. data/lib/pact_broker/api/decorators/webhook_request_template_decorator.rb +1 -1
  190. data/lib/pact_broker/api/decorators/webhooks_decorator.rb +3 -3
  191. data/lib/pact_broker/api/pact_broker_urls.rb +125 -69
  192. data/lib/pact_broker/api/paths.rb +2 -2
  193. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +16 -17
  194. data/lib/pact_broker/api/resources.rb +1 -1
  195. data/lib/pact_broker/api/resources/all_webhooks.rb +14 -6
  196. data/lib/pact_broker/api/resources/authentication.rb +1 -1
  197. data/lib/pact_broker/api/resources/authorization.rb +37 -0
  198. data/lib/pact_broker/api/resources/badge.rb +8 -8
  199. data/lib/pact_broker/api/resources/base_resource.rb +1 -1
  200. data/lib/pact_broker/api/resources/can_i_deploy.rb +13 -13
  201. data/lib/pact_broker/api/resources/can_i_deploy_badge.rb +7 -7
  202. data/lib/pact_broker/api/resources/can_i_deploy_pacticipant_version.rb +23 -18
  203. data/lib/pact_broker/api/resources/clean.rb +3 -3
  204. data/lib/pact_broker/api/resources/currently_deployed_versions_for_environment.rb +75 -0
  205. data/lib/pact_broker/api/resources/currently_supported_versions_for_environment.rb +70 -0
  206. data/lib/pact_broker/api/resources/dashboard.rb +3 -3
  207. data/lib/pact_broker/api/resources/default_base_resource.rb +47 -20
  208. data/lib/pact_broker/api/resources/deployed_version.rb +94 -0
  209. data/lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb +89 -0
  210. data/lib/pact_broker/api/resources/environment.rb +76 -0
  211. data/lib/pact_broker/api/resources/environments.rb +79 -0
  212. data/lib/pact_broker/api/resources/error_handler.rb +4 -4
  213. data/lib/pact_broker/api/resources/error_response_body_generator.rb +3 -3
  214. data/lib/pact_broker/api/resources/error_test.rb +2 -2
  215. data/lib/pact_broker/api/resources/group.rb +2 -2
  216. data/lib/pact_broker/api/resources/index.rb +91 -70
  217. data/lib/pact_broker/api/resources/integration.rb +1 -1
  218. data/lib/pact_broker/api/resources/integrations.rb +3 -3
  219. data/lib/pact_broker/api/resources/label.rb +2 -2
  220. data/lib/pact_broker/api/resources/latest_pact.rb +5 -5
  221. data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
  222. data/lib/pact_broker/api/resources/latest_provider_pacts.rb +3 -3
  223. data/lib/pact_broker/api/resources/latest_verification_for_latest_pact.rb +5 -1
  224. data/lib/pact_broker/api/resources/latest_verification_for_pact.rb +5 -1
  225. data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +5 -5
  226. data/lib/pact_broker/api/resources/latest_version.rb +1 -1
  227. data/lib/pact_broker/api/resources/matrix.rb +18 -13
  228. data/lib/pact_broker/api/resources/matrix_badge.rb +1 -1
  229. data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +2 -2
  230. data/lib/pact_broker/api/resources/metadata_resource_methods.rb +2 -2
  231. data/lib/pact_broker/api/resources/metrics.rb +1 -1
  232. data/lib/pact_broker/api/resources/pact.rb +17 -27
  233. data/lib/pact_broker/api/resources/pact_content_diff.rb +3 -3
  234. data/lib/pact_broker/api/resources/pact_triggered_webhooks.rb +7 -3
  235. data/lib/pact_broker/api/resources/pact_version.rb +2 -2
  236. data/lib/pact_broker/api/resources/pact_versions.rb +3 -3
  237. data/lib/pact_broker/api/resources/pact_webhooks.rb +7 -8
  238. data/lib/pact_broker/api/resources/pact_webhooks_status.rb +2 -2
  239. data/lib/pact_broker/api/resources/pacticipant.rb +51 -15
  240. data/lib/pact_broker/api/resources/pacticipant_resource_methods.rb +1 -1
  241. data/lib/pact_broker/api/resources/{webhooks.rb → pacticipant_webhooks.rb} +12 -8
  242. data/lib/pact_broker/api/resources/pacticipants.rb +13 -8
  243. data/lib/pact_broker/api/resources/pacticipants_for_label.rb +2 -2
  244. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +4 -4
  245. data/lib/pact_broker/api/resources/provider_pacts.rb +3 -3
  246. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +10 -6
  247. data/lib/pact_broker/api/resources/publish_contracts.rb +81 -0
  248. data/lib/pact_broker/api/resources/relationships.rb +2 -2
  249. data/lib/pact_broker/api/resources/released_version.rb +84 -0
  250. data/lib/pact_broker/api/resources/released_versions_for_version_and_environment.rb +94 -0
  251. data/lib/pact_broker/api/resources/tag.rb +1 -1
  252. data/lib/pact_broker/api/resources/tagged_pact_versions.rb +4 -4
  253. data/lib/pact_broker/api/resources/triggered_webhook_logs.rb +16 -8
  254. data/lib/pact_broker/api/resources/verification.rb +17 -7
  255. data/lib/pact_broker/api/resources/verification_triggered_webhooks.rb +7 -3
  256. data/lib/pact_broker/api/resources/verifications.rb +13 -18
  257. data/lib/pact_broker/api/resources/version.rb +49 -11
  258. data/lib/pact_broker/api/resources/versions.rb +6 -6
  259. data/lib/pact_broker/api/resources/webhook.rb +17 -9
  260. data/lib/pact_broker/api/resources/webhook_execution.rb +18 -14
  261. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +31 -0
  262. data/lib/pact_broker/app.rb +37 -35
  263. data/lib/pact_broker/application_context.rb +5 -5
  264. data/lib/pact_broker/badges/service.rb +22 -22
  265. data/lib/pact_broker/build_http_options.rb +2 -2
  266. data/lib/pact_broker/certificates/service.rb +4 -4
  267. data/lib/pact_broker/config/load.rb +4 -4
  268. data/lib/pact_broker/config/repository.rb +1 -1
  269. data/lib/pact_broker/config/save.rb +4 -4
  270. data/lib/pact_broker/config/setting.rb +28 -24
  271. data/lib/pact_broker/config/space_delimited_integer_list.rb +3 -3
  272. data/lib/pact_broker/config/space_delimited_string_list.rb +3 -3
  273. data/lib/pact_broker/configuration.rb +27 -20
  274. data/lib/pact_broker/constants.rb +2 -2
  275. data/lib/pact_broker/contracts/contract_to_publish.rb +19 -0
  276. data/lib/pact_broker/contracts/contracts_publication_results.rb +14 -0
  277. data/lib/pact_broker/contracts/contracts_to_publish.rb +11 -0
  278. data/lib/pact_broker/contracts/notice.rb +21 -0
  279. data/lib/pact_broker/contracts/service.rb +264 -0
  280. data/lib/pact_broker/date_helper.rb +48 -46
  281. data/lib/pact_broker/db.rb +11 -7
  282. data/lib/pact_broker/db/clean.rb +4 -8
  283. data/lib/pact_broker/db/clean_incremental.rb +8 -6
  284. data/lib/pact_broker/db/data_migrations/delete_deprecated_webhook_executions.rb +1 -1
  285. data/lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb +1 -1
  286. data/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications.rb +1 -1
  287. data/lib/pact_broker/db/data_migrations/set_created_at_for_latest_pact_publications.rb +1 -1
  288. data/lib/pact_broker/db/data_migrations/set_created_at_for_latest_verifications.rb +1 -1
  289. data/lib/pact_broker/db/data_migrations/set_extra_columns_for_tags.rb +3 -3
  290. data/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value.rb +1 -1
  291. data/lib/pact_broker/db/data_migrations/set_pacticipant_display_name.rb +23 -0
  292. data/lib/pact_broker/db/data_migrations/set_pacticipant_ids_for_verifications.rb +1 -1
  293. data/lib/pact_broker/db/data_migrations/set_pacticipant_main_branch.rb +53 -0
  294. data/lib/pact_broker/db/data_migrations/set_webhook_uuid.rb +24 -0
  295. data/lib/pact_broker/db/data_migrations/set_webhooks_enabled.rb +1 -1
  296. data/lib/pact_broker/db/delete_overwritten_data.rb +7 -7
  297. data/lib/pact_broker/db/log_quietener.rb +1 -1
  298. data/lib/pact_broker/db/migrate.rb +4 -4
  299. data/lib/pact_broker/db/migrate_data.rb +4 -1
  300. data/lib/pact_broker/db/models.rb +17 -12
  301. data/lib/pact_broker/db/seed_example_data.rb +9 -4
  302. data/lib/pact_broker/db/validate_encoding.rb +4 -4
  303. data/lib/pact_broker/db/version.rb +1 -1
  304. data/lib/pact_broker/deployments/currently_deployed_version_id.rb +30 -0
  305. data/lib/pact_broker/deployments/deployed_version.rb +115 -0
  306. data/lib/pact_broker/deployments/deployed_version_service.rb +85 -0
  307. data/lib/pact_broker/deployments/environment.rb +49 -0
  308. data/lib/pact_broker/deployments/environment_service.rb +52 -0
  309. data/lib/pact_broker/deployments/released_version.rb +83 -0
  310. data/lib/pact_broker/deployments/released_version_service.rb +47 -0
  311. data/lib/pact_broker/diagnostic/app.rb +8 -8
  312. data/lib/pact_broker/diagnostic/resources/base_resource.rb +2 -2
  313. data/lib/pact_broker/diagnostic/resources/dependencies.rb +3 -3
  314. data/lib/pact_broker/diagnostic/resources/heartbeat.rb +1 -1
  315. data/lib/pact_broker/doc/controllers/app.rb +10 -10
  316. data/lib/pact_broker/doc/views/can-i-deploy.markdown +4 -2
  317. data/lib/pact_broker/doc/views/index/environment.markdown +37 -0
  318. data/lib/pact_broker/doc/views/index/environments.markdown +53 -0
  319. data/lib/pact_broker/doc/views/index/latest-pact-versions.markdown +1 -1
  320. data/lib/pact_broker/doc/views/index/pacticipant-version-tag.markdown +1 -0
  321. data/lib/pact_broker/doc/views/index/pacticipants.markdown +25 -3
  322. data/lib/pact_broker/doc/views/index/publish-contracts.markdown +120 -0
  323. data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +22 -11
  324. data/lib/pact_broker/doc/views/webhooks.markdown +5 -3
  325. data/lib/pact_broker/domain.rb +6 -6
  326. data/lib/pact_broker/domain/index_item.rb +27 -8
  327. data/lib/pact_broker/domain/label.rb +1 -2
  328. data/lib/pact_broker/domain/order_versions.rb +2 -2
  329. data/lib/pact_broker/domain/pact.rb +14 -7
  330. data/lib/pact_broker/domain/pacticipant.rb +27 -18
  331. data/lib/pact_broker/domain/tag.rb +5 -3
  332. data/lib/pact_broker/domain/verification.rb +8 -8
  333. data/lib/pact_broker/domain/version.rb +55 -10
  334. data/lib/pact_broker/domain/webhook.rb +14 -15
  335. data/lib/pact_broker/domain/webhook_request.rb +14 -18
  336. data/lib/pact_broker/errors.rb +7 -7
  337. data/lib/pact_broker/errors/error_logger.rb +3 -3
  338. data/lib/pact_broker/events/event.rb +5 -0
  339. data/lib/pact_broker/events/publisher.rb +9 -0
  340. data/lib/pact_broker/events/subscriber.rb +42 -0
  341. data/lib/pact_broker/feature_toggle.rb +2 -2
  342. data/lib/pact_broker/groups/service.rb +2 -2
  343. data/lib/pact_broker/hash_refinements.rb +12 -12
  344. data/lib/pact_broker/index/service.rb +69 -36
  345. data/lib/pact_broker/integrations/integration.rb +5 -5
  346. data/lib/pact_broker/integrations/service.rb +11 -7
  347. data/lib/pact_broker/labels/repository.rb +2 -2
  348. data/lib/pact_broker/labels/service.rb +1 -1
  349. data/lib/pact_broker/locale/en.yml +54 -14
  350. data/lib/pact_broker/logging.rb +3 -3
  351. data/lib/pact_broker/logging/default_formatter.rb +3 -3
  352. data/lib/pact_broker/matrix/aggregated_row.rb +4 -4
  353. data/lib/pact_broker/matrix/can_i_deploy_query_schema.rb +17 -2
  354. data/lib/pact_broker/matrix/deployment_status_summary.rb +78 -38
  355. data/lib/pact_broker/matrix/every_row.rb +2 -2
  356. data/lib/pact_broker/matrix/head_row.rb +2 -2
  357. data/lib/pact_broker/matrix/integration.rb +6 -6
  358. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +19 -3
  359. data/lib/pact_broker/matrix/parse_query.rb +47 -24
  360. data/lib/pact_broker/matrix/query_builder.rb +10 -10
  361. data/lib/pact_broker/matrix/query_results.rb +9 -4
  362. data/lib/pact_broker/matrix/query_results_with_deployment_status_summary.rb +3 -3
  363. data/lib/pact_broker/matrix/quick_row.rb +32 -34
  364. data/lib/pact_broker/matrix/reason.rb +88 -1
  365. data/lib/pact_broker/matrix/repository.rb +137 -66
  366. data/lib/pact_broker/matrix/resolved_selector.rb +82 -7
  367. data/lib/pact_broker/matrix/row.rb +6 -6
  368. data/lib/pact_broker/matrix/service.rb +44 -14
  369. data/lib/pact_broker/matrix/unresolved_selector.rb +22 -2
  370. data/lib/pact_broker/messages.rb +17 -5
  371. data/lib/pact_broker/metrics/service.rb +16 -15
  372. data/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb +5 -5
  373. data/lib/pact_broker/pacticipants/generate_display_name.rb +27 -0
  374. data/lib/pact_broker/pacticipants/repository.rb +34 -16
  375. data/lib/pact_broker/pacticipants/service.rb +19 -19
  376. data/lib/pact_broker/pacts/all_pact_publications.rb +6 -6
  377. data/lib/pact_broker/pacts/build_verifiable_pact_notices.rb +8 -8
  378. data/lib/pact_broker/pacts/content.rb +23 -21
  379. data/lib/pact_broker/pacts/create_formatted_diff.rb +3 -3
  380. data/lib/pact_broker/pacts/diff.rb +8 -8
  381. data/lib/pact_broker/pacts/eager_loaders.rb +1 -1
  382. data/lib/pact_broker/pacts/generate_interaction_sha.rb +2 -2
  383. data/lib/pact_broker/pacts/generate_sha.rb +10 -10
  384. data/lib/pact_broker/pacts/head_pact.rb +1 -1
  385. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +2 -2
  386. data/lib/pact_broker/pacts/latest_pact_publications.rb +2 -2
  387. data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +1 -1
  388. data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +2 -2
  389. data/lib/pact_broker/pacts/lazy_loaders.rb +2 -2
  390. data/lib/pact_broker/pacts/merger.rb +2 -2
  391. data/lib/pact_broker/pacts/order_hash_keys.rb +1 -1
  392. data/lib/pact_broker/pacts/pact_params.rb +7 -7
  393. data/lib/pact_broker/pacts/pact_publication.rb +19 -13
  394. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +7 -49
  395. data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +70 -0
  396. data/lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb +106 -0
  397. data/lib/pact_broker/pacts/pact_version.rb +46 -14
  398. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +51 -47
  399. data/lib/pact_broker/pacts/parse.rb +1 -1
  400. data/lib/pact_broker/pacts/placeholder_pact.rb +1 -1
  401. data/lib/pact_broker/pacts/repository.rb +27 -23
  402. data/lib/pact_broker/pacts/selected_pact.rb +5 -1
  403. data/lib/pact_broker/pacts/selector.rb +124 -6
  404. data/lib/pact_broker/pacts/selectors.rb +5 -1
  405. data/lib/pact_broker/pacts/service.rb +102 -32
  406. data/lib/pact_broker/pacts/sort_content.rb +14 -9
  407. data/lib/pact_broker/pacts/squash_pacts_for_verification.rb +0 -1
  408. data/lib/pact_broker/pacts/verifiable_pact.rb +5 -3
  409. data/lib/pact_broker/pacts/verifiable_pact_messages.rb +82 -37
  410. data/lib/pact_broker/policies.rb +1 -1
  411. data/lib/pact_broker/project_root.rb +2 -2
  412. data/lib/pact_broker/relationships/groupify.rb +1 -1
  413. data/lib/pact_broker/repositories.rb +9 -9
  414. data/lib/pact_broker/services.rb +53 -15
  415. data/lib/pact_broker/string_refinements.rb +10 -4
  416. data/lib/pact_broker/tags/eager_loaders.rb +2 -2
  417. data/lib/pact_broker/tags/head_pact_tags.rb +2 -2
  418. data/lib/pact_broker/tags/repository.rb +2 -2
  419. data/lib/pact_broker/tags/service.rb +1 -1
  420. data/lib/pact_broker/tags/tag_with_latest_flag.rb +2 -2
  421. data/lib/pact_broker/tasks.rb +5 -5
  422. data/lib/pact_broker/tasks/clean_task.rb +12 -12
  423. data/lib/pact_broker/tasks/data_migration_task.rb +4 -4
  424. data/lib/pact_broker/tasks/delete_overwritten_data_task.rb +8 -8
  425. data/lib/pact_broker/tasks/migration_task.rb +5 -5
  426. data/lib/pact_broker/tasks/version_task.rb +3 -3
  427. data/lib/pact_broker/test/http_test_data_builder.rb +72 -31
  428. data/lib/pact_broker/test/test_data_builder.rb +119 -52
  429. data/lib/pact_broker/ui.rb +3 -3
  430. data/lib/pact_broker/ui/app.rb +9 -9
  431. data/lib/pact_broker/ui/controllers/base_controller.rb +6 -6
  432. data/lib/pact_broker/ui/controllers/can_i_deploy.rb +9 -9
  433. data/lib/pact_broker/ui/controllers/clusters.rb +5 -5
  434. data/lib/pact_broker/ui/controllers/error_test.rb +3 -3
  435. data/lib/pact_broker/ui/controllers/groups.rb +4 -4
  436. data/lib/pact_broker/ui/controllers/index.rb +28 -15
  437. data/lib/pact_broker/ui/controllers/matrix.rb +11 -11
  438. data/lib/pact_broker/ui/controllers/pacts.rb +1 -1
  439. data/lib/pact_broker/ui/helpers/matrix_helper.rb +12 -8
  440. data/lib/pact_broker/ui/helpers/url_helper.rb +3 -3
  441. data/lib/pact_broker/ui/view_models/index_item.rb +29 -15
  442. data/lib/pact_broker/ui/view_models/index_items.rb +2 -2
  443. data/lib/pact_broker/ui/view_models/matrix_deployed_version.rb +37 -0
  444. data/lib/pact_broker/ui/view_models/matrix_line.rb +45 -11
  445. data/lib/pact_broker/ui/view_models/matrix_lines.rb +1 -1
  446. data/lib/pact_broker/ui/view_models/matrix_released_version.rb +37 -0
  447. data/lib/pact_broker/ui/view_models/matrix_tag.rb +3 -3
  448. data/lib/pact_broker/ui/views/index/show-with-tags.haml +60 -14
  449. data/lib/pact_broker/ui/views/index/show.haml +23 -2
  450. data/lib/pact_broker/ui/views/matrix/show.haml +33 -9
  451. data/lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb +1 -1
  452. data/lib/pact_broker/verifications/latest_verification_for_consumer_version_tag.rb +1 -1
  453. data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +1 -1
  454. data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +1 -1
  455. data/lib/pact_broker/verifications/repository.rb +9 -5
  456. data/lib/pact_broker/verifications/sequence.rb +2 -2
  457. data/lib/pact_broker/verifications/service.rb +33 -17
  458. data/lib/pact_broker/version.rb +1 -1
  459. data/lib/pact_broker/versions/eager_loaders.rb +6 -6
  460. data/lib/pact_broker/versions/latest_version.rb +1 -1
  461. data/lib/pact_broker/versions/parse_semantic_version.rb +2 -2
  462. data/lib/pact_broker/versions/repository.rb +47 -15
  463. data/lib/pact_broker/versions/sequence.rb +1 -1
  464. data/lib/pact_broker/versions/service.rb +25 -2
  465. data/lib/pact_broker/webhooks/check_host_whitelist.rb +1 -1
  466. data/lib/pact_broker/webhooks/event_listener.rb +86 -0
  467. data/lib/pact_broker/webhooks/execution.rb +3 -3
  468. data/lib/pact_broker/webhooks/execution_configuration.rb +1 -1
  469. data/lib/pact_broker/webhooks/execution_configuration_creator.rb +2 -2
  470. data/lib/pact_broker/webhooks/http_request_with_redacted_headers.rb +1 -1
  471. data/lib/pact_broker/webhooks/http_response_with_utf_8_safe_body.rb +1 -1
  472. data/lib/pact_broker/webhooks/job.rb +5 -5
  473. data/lib/pact_broker/webhooks/latest_triggered_webhook.rb +17 -2
  474. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +57 -15
  475. data/lib/pact_broker/webhooks/redact_logs.rb +3 -3
  476. data/lib/pact_broker/webhooks/render.rb +4 -5
  477. data/lib/pact_broker/webhooks/repository.rb +69 -75
  478. data/lib/pact_broker/webhooks/service.rb +52 -134
  479. data/lib/pact_broker/webhooks/status.rb +3 -1
  480. data/lib/pact_broker/webhooks/trigger_service.rb +75 -70
  481. data/lib/pact_broker/webhooks/triggered_webhook.rb +15 -12
  482. data/lib/pact_broker/webhooks/webhook.rb +43 -6
  483. data/lib/pact_broker/webhooks/webhook_event.rb +7 -7
  484. data/lib/pact_broker/webhooks/webhook_execution_result.rb +8 -3
  485. data/lib/pact_broker/webhooks/webhook_request_logger.rb +9 -7
  486. data/lib/pact_broker/webhooks/webhook_request_template.rb +41 -6
  487. data/lib/rack/hal_browser.rb +1 -1
  488. data/lib/rack/hal_browser/redirect.rb +9 -9
  489. data/lib/rack/pact_broker/add_pact_broker_version_header.rb +2 -2
  490. data/lib/rack/pact_broker/convert_404_to_hal.rb +2 -2
  491. data/lib/rack/pact_broker/convert_file_extension_to_accept_header.rb +1 -1
  492. data/lib/rack/pact_broker/database_transaction.rb +3 -3
  493. data/lib/rack/pact_broker/invalid_uri_protection.rb +5 -5
  494. data/lib/rack/pact_broker/no_auth.rb +1 -1
  495. data/lib/rack/pact_broker/request_target.rb +8 -8
  496. data/lib/rack/pact_broker/reset_thread_data.rb +1 -1
  497. data/lib/rack/pact_broker/set_base_url.rb +35 -5
  498. data/lib/rack/pact_broker/ui_authentication.rb +3 -3
  499. data/lib/rack/pact_broker/ui_request_filter.rb +1 -1
  500. data/lib/sequel/extensions/statement_timeout.rb +9 -9
  501. data/pact_broker.gemspec +26 -25
  502. data/public/javascripts/clipboard.js +8 -2
  503. data/public/javascripts/matrix.js +11 -6
  504. data/public/stylesheets/index.css +14 -1
  505. data/regression/can_i_deploy_spec.rb +1 -1
  506. data/regression/index_spec.rb +3 -3
  507. data/regression/regression_helper.rb +9 -9
  508. data/scaffolding/README.md +23 -0
  509. data/scaffolding/run.rb +242 -0
  510. data/scaffolding/templates/decorator.rb.erb +13 -0
  511. data/scaffolding/templates/decorator_spec.erb.rb +0 -0
  512. data/scaffolding/templates/migration.erb +12 -0
  513. data/scaffolding/templates/model.erb +14 -0
  514. data/scaffolding/templates/repository.rb.erb +18 -0
  515. data/scaffolding/templates/repository_spec.rb.erb +9 -0
  516. data/scaffolding/templates/resource.erb +46 -0
  517. data/scaffolding/templates/resource_spec.rb.erb +78 -0
  518. data/scaffolding/templates/service.rb.erb +22 -0
  519. data/scaffolding/templates/service_spec.rb.erb +9 -0
  520. data/script/data/environments.rb +45 -0
  521. data/script/demonstrate-version-branches.rb +2 -2
  522. data/script/docker-container/test.sh +1 -1
  523. data/script/generate-certificates-for-webooks-certificate-spec.rb +1 -1
  524. data/script/insert-self-signed-certificate-from-url.rb +5 -5
  525. data/script/pry.rb +18 -12
  526. data/script/query.rb +5 -5
  527. data/script/reproduce-issue-can-i-deploy-ignore.rb +48 -0
  528. data/script/reproduce-issue-expand-currently-deployed.rb +47 -0
  529. data/script/reproduce-issue-starting-up.rb +12 -7
  530. data/script/reproduce-issue.rb +7 -2
  531. data/script/run-with-ssl.rb +8 -8
  532. data/script/seed-example-matrix.rb +11 -11
  533. data/script/seed-for-webhook-test.rb +22 -22
  534. data/script/seed-matrix.rb +20 -20
  535. data/script/seed.rb +25 -25
  536. data/script/test/approval-all.sh +6 -0
  537. data/script/webhook-server.ru +3 -3
  538. data/spec/features/base_equality_only_on_content_that_affects_verification_results_spec.rb +3 -3
  539. data/spec/features/can_i_deploy_spec.rb +1 -1
  540. data/spec/features/create_environment_spec.rb +47 -0
  541. data/spec/features/create_pacticipant_spec.rb +13 -7
  542. data/spec/features/create_tag_spec.rb +32 -0
  543. data/spec/features/create_version_spec.rb +40 -26
  544. data/spec/features/create_webhook_spec.rb +10 -10
  545. data/spec/features/delete_environment_spec.rb +16 -0
  546. data/spec/features/delete_label_spec.rb +1 -1
  547. data/spec/features/delete_pact_spec.rb +1 -1
  548. data/spec/features/delete_verification_spec.rb +3 -3
  549. data/spec/features/delete_version_spec.rb +1 -1
  550. data/spec/features/delete_webhook_spec.rb +5 -1
  551. data/spec/features/edit_webhook_spec.rb +8 -8
  552. data/spec/features/end_deployment_spec.rb +29 -0
  553. data/spec/features/end_support_spec.rb +67 -0
  554. data/spec/features/execute_unsaved_webhook_spec.rb +7 -10
  555. data/spec/features/execute_webhook_spec.rb +5 -5
  556. data/spec/features/get_can_i_deploy_badge_spec.rb +2 -2
  557. data/spec/features/get_currently_deployed_versions_for_environment_spec.rb +59 -0
  558. data/spec/features/get_currently_deployed_versions_for_version_spec.rb +27 -0
  559. data/spec/features/get_currently_supported_versions_for_environment_spec.rb +57 -0
  560. data/spec/features/get_dashboard_spec.rb +1 -1
  561. data/spec/features/get_deployed_versions_for_version_and_environment.rb +27 -0
  562. data/spec/features/get_diff_spec.rb +5 -5
  563. data/spec/features/get_environment_spec.rb +19 -0
  564. data/spec/features/get_environments_spec.rb +30 -0
  565. data/spec/features/get_integrations_dot_file_spec.rb +2 -2
  566. data/spec/features/get_integrations_spec.rb +1 -1
  567. data/spec/features/get_label_spec.rb +1 -1
  568. data/spec/features/get_latest_pact_badge_spec.rb +7 -7
  569. data/spec/features/get_latest_tagged_pact_badge_spec.rb +8 -8
  570. data/spec/features/get_latest_untagged_pact_badge_spec.rb +8 -8
  571. data/spec/features/get_latest_untagged_pact_spec.rb +1 -1
  572. data/spec/features/get_latest_verification_for_pact_spec.rb +2 -2
  573. data/spec/features/get_matrix_badge_spec.rb +10 -10
  574. data/spec/features/get_matrix_for_consumer_and_provider_spec.rb +3 -6
  575. data/spec/features/get_matrix_spec.rb +5 -5
  576. data/spec/features/get_pact_version.rb +2 -2
  577. data/spec/features/get_pact_versions_spec.rb +1 -1
  578. data/spec/features/get_previous_distinct_version.rb +5 -5
  579. data/spec/features/get_provider_pacts_for_verification_spec.rb +16 -5
  580. data/spec/features/get_released_versions_for_version_and_environment.rb +27 -0
  581. data/spec/features/get_tagged_pact_versions_spec.rb +1 -1
  582. data/spec/features/get_triggered_webhooks_for_pact_spec.rb +1 -1
  583. data/spec/features/get_triggered_webhooks_for_verification_spec.rb +1 -1
  584. data/spec/features/get_verifications_for_consumer_version_spec.rb +1 -1
  585. data/spec/features/get_version_spec.rb +2 -2
  586. data/spec/features/get_versions_spec.rb +2 -2
  587. data/spec/features/label_pacticipant_spec.rb +3 -3
  588. data/spec/features/merge_pact_spec.rb +8 -8
  589. data/spec/features/pending_pacts_with_tags_spec.rb +138 -0
  590. data/spec/features/publish_not_a_pact_spec.rb +5 -5
  591. data/spec/features/publish_pact_all_in_one_approval_spec.rb +72 -0
  592. data/spec/features/publish_pact_all_in_one_spec.rb +43 -0
  593. data/spec/features/publish_pact_spec.rb +41 -6
  594. data/spec/features/publish_verification_spec.rb +11 -11
  595. data/spec/features/record_deployment_spec.rb +93 -0
  596. data/spec/features/record_release_spec.rb +84 -0
  597. data/spec/features/record_undeployment_spec.rb +67 -0
  598. data/spec/features/tag_version_spec.rb +2 -2
  599. data/spec/features/update_environment_spec.rb +44 -0
  600. data/spec/features/update_matrix_spec.rb +5 -5
  601. data/spec/features/update_pacticipant_spec.rb +87 -12
  602. data/spec/features/update_version_spec.rb +155 -0
  603. data/spec/features/update_webhook_spec.rb +6 -6
  604. data/spec/features/wip_pacts_spec.rb +64 -43
  605. data/spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json +57 -0
  606. data/spec/fixtures/approvals/modifiable_resources.approved.json +24 -3
  607. data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +166 -0
  608. data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +158 -0
  609. data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +158 -0
  610. data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +149 -0
  611. data/spec/fixtures/approvals/publish_contract_with_validation_error.approved.json +42 -0
  612. data/spec/fixtures/approvals/publish_contracts_results_decorator.approved.json +61 -0
  613. data/spec/integration/app_spec.rb +41 -41
  614. data/spec/integration/ui/index_spec.rb +4 -4
  615. data/spec/integration/ui/matrix_spec.rb +3 -3
  616. data/spec/integration/webhooks/certificate_spec.rb +7 -7
  617. data/spec/lib/pact/doc/generator_spec.rb +7 -7
  618. data/spec/lib/pact/doc/interaction_view_model_spec.rb +16 -16
  619. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +9 -9
  620. data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +3 -3
  621. data/spec/lib/pact_broker/api/contracts/environment_schema_spec.rb +91 -0
  622. data/spec/lib/pact_broker/api/contracts/pacticipant_schema_spec.rb +46 -0
  623. data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +114 -0
  624. data/spec/lib/pact_broker/api/contracts/put_pact_params_contract_spec.rb +6 -6
  625. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_combinations_spec.rb +76 -0
  626. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_spec.rb +158 -4
  627. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_query_schema_spec.rb +1 -1
  628. data/spec/lib/pact_broker/api/contracts/verification_contract_spec.rb +4 -4
  629. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +26 -26
  630. data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +30 -30
  631. data/spec/lib/pact_broker/api/decorators/embedded_label_decorator_spec.rb +2 -2
  632. data/spec/lib/pact_broker/api/decorators/embedded_tag_decorator_spec.rb +5 -5
  633. data/spec/lib/pact_broker/api/decorators/embedded_version_decorator_spec.rb +3 -3
  634. data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +17 -17
  635. data/spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb +3 -3
  636. data/spec/lib/pact_broker/api/decorators/integrations_decorator_spec.rb +3 -3
  637. data/spec/lib/pact_broker/api/decorators/label_decorator_spec.rb +2 -2
  638. data/spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb +4 -4
  639. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +50 -25
  640. data/spec/lib/pact_broker/api/decorators/pact_collection_decorator_spec.rb +6 -6
  641. data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +25 -25
  642. data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +22 -17
  643. data/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb +17 -14
  644. data/spec/lib/pact_broker/api/decorators/pacticipant_collection_decorator_spec.rb +7 -7
  645. data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +63 -50
  646. data/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb +7 -7
  647. data/spec/lib/pact_broker/api/decorators/publish_contracts_results_decorator_spec.rb +53 -0
  648. data/spec/lib/pact_broker/api/decorators/reason_decorator_spec.rb +27 -8
  649. data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +4 -4
  650. data/spec/lib/pact_broker/api/decorators/representable_pact_spec.rb +7 -7
  651. data/spec/lib/pact_broker/api/decorators/tag_decorator_spec.rb +4 -4
  652. data/spec/lib/pact_broker/api/decorators/tagged_pact_versions_decorator_spec.rb +4 -4
  653. data/spec/lib/pact_broker/api/decorators/triggered_webhook_decorator_spec.rb +18 -15
  654. data/spec/lib/pact_broker/api/decorators/triggered_webhooks_decorator_spec.rb +5 -5
  655. data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +11 -11
  656. data/spec/lib/pact_broker/api/decorators/verifiable_pacts_decorator_spec.rb +3 -3
  657. data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +44 -1
  658. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -15
  659. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +9 -9
  660. data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +93 -48
  661. data/spec/lib/pact_broker/api/decorators/versions_decorator_spec.rb +7 -7
  662. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +59 -59
  663. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +15 -15
  664. data/spec/lib/pact_broker/api/decorators/webhook_request_template_decorator_spec.rb +13 -13
  665. data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +10 -10
  666. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +36 -10
  667. data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +30 -30
  668. data/spec/lib/pact_broker/api/renderers/integrations_dot_renderer_spec.rb +4 -4
  669. data/spec/lib/pact_broker/api/resources/all_webhooks_spec.rb +32 -41
  670. data/spec/lib/pact_broker/api/resources/badge_spec.rb +17 -17
  671. data/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +6 -6
  672. data/spec/lib/pact_broker/api/resources/can_i_deploy_pacticipant_version_spec.rb +9 -9
  673. data/spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb +7 -7
  674. data/spec/lib/pact_broker/api/resources/dashboard_spec.rb +1 -1
  675. data/spec/lib/pact_broker/api/resources/default_base_resource_approval_spec.rb +12 -11
  676. data/spec/lib/pact_broker/api/resources/default_base_resource_spec.rb +25 -24
  677. data/spec/lib/pact_broker/api/resources/error_response_body_generator_spec.rb +11 -11
  678. data/spec/lib/pact_broker/api/resources/group_spec.rb +11 -11
  679. data/spec/lib/pact_broker/api/resources/latest_pact_spec.rb +15 -15
  680. data/spec/lib/pact_broker/api/resources/latest_provider_pacts_spec.rb +6 -6
  681. data/spec/lib/pact_broker/api/resources/latest_verifications_for_consumer_version_spec.rb +8 -8
  682. data/spec/lib/pact_broker/api/resources/matrix_badge_spec.rb +1 -1
  683. data/spec/lib/pact_broker/api/resources/matrix_spec.rb +10 -10
  684. data/spec/lib/pact_broker/api/resources/pact_spec.rb +24 -24
  685. data/spec/lib/pact_broker/api/resources/pact_triggered_webhooks_spec.rb +4 -4
  686. data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +2 -5
  687. data/spec/lib/pact_broker/api/resources/{webhooks_spec.rb → pacticipant_webhooks_spec.rb} +19 -19
  688. data/spec/lib/pact_broker/api/resources/pacticipants_spec.rb +18 -22
  689. data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +17 -17
  690. data/spec/lib/pact_broker/api/resources/provider_pacts_spec.rb +8 -8
  691. data/spec/lib/pact_broker/api/resources/released_version_spec.rb +61 -0
  692. data/spec/lib/pact_broker/api/resources/tag_spec.rb +3 -3
  693. data/spec/lib/pact_broker/api/resources/tagged_pact_versions_spec.rb +7 -7
  694. data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +9 -6
  695. data/spec/lib/pact_broker/api/resources/verification_spec.rb +76 -7
  696. data/spec/lib/pact_broker/api/resources/verification_triggered_webhooks_spec.rb +4 -4
  697. data/spec/lib/pact_broker/api/resources/verifications_spec.rb +22 -28
  698. data/spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb +56 -0
  699. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +10 -10
  700. data/spec/lib/pact_broker/api/resources/webhook_spec.rb +15 -15
  701. data/spec/lib/pact_broker/app_spec.rb +43 -43
  702. data/spec/lib/pact_broker/badges/service_spec.rb +6 -6
  703. data/spec/lib/pact_broker/build_http_options_spec.rb +5 -5
  704. data/spec/lib/pact_broker/certificates/service_spec.rb +7 -7
  705. data/spec/lib/pact_broker/config/load_spec.rb +11 -11
  706. data/spec/lib/pact_broker/config/save_and_load_spec.rb +2 -2
  707. data/spec/lib/pact_broker/config/save_spec.rb +29 -29
  708. data/spec/lib/pact_broker/config/space_delimited_integer_list_spec.rb +1 -1
  709. data/spec/lib/pact_broker/config/space_delimited_string_list_spec.rb +1 -1
  710. data/spec/lib/pact_broker/configuration_spec.rb +9 -9
  711. data/spec/lib/pact_broker/contracts/service_spec.rb +108 -0
  712. data/spec/lib/pact_broker/db/clean_incremental_spec.rb +12 -11
  713. data/spec/lib/pact_broker/db/clean_old_spec.rb +2 -4
  714. data/spec/lib/pact_broker/db/clean_spec.rb +5 -7
  715. data/spec/lib/pact_broker/db/data_migrations/migrate_webhook_headers_spec.rb +1 -1
  716. data/spec/lib/pact_broker/db/data_migrations/set_consumer_ids_for_pact_publications_spec.rb +6 -6
  717. data/spec/lib/pact_broker/db/data_migrations/set_latest_version_sequence_value_spec.rb +8 -8
  718. data/spec/lib/pact_broker/db/data_migrations/set_pacticipant_main_branch_spec.rb +41 -0
  719. data/spec/lib/pact_broker/db/delete_overwritten_data_spec.rb +1 -1
  720. data/spec/lib/pact_broker/db/log_quietener_spec.rb +1 -1
  721. data/spec/lib/pact_broker/db/validate_encoding_spec.rb +8 -8
  722. data/spec/lib/pact_broker/deployments/deployed_version_spec.rb +109 -0
  723. data/spec/lib/pact_broker/deployments/environment_service_spec.rb +37 -0
  724. data/spec/lib/pact_broker/deployments/environment_spec.rb +27 -0
  725. data/spec/lib/pact_broker/diagnostic/resources/dependencies_spec.rb +9 -9
  726. data/spec/lib/pact_broker/diagnostic/resources/heartbeat_spec.rb +5 -5
  727. data/spec/lib/pact_broker/doc/controllers/app_spec.rb +4 -4
  728. data/spec/lib/pact_broker/doc/coverage_spec.rb +5 -5
  729. data/spec/lib/pact_broker/domain/group_spec.rb +7 -7
  730. data/spec/lib/pact_broker/domain/index_item_spec.rb +3 -3
  731. data/spec/lib/pact_broker/domain/order_versions_spec.rb +26 -26
  732. data/spec/lib/pact_broker/domain/pact_spec.rb +3 -3
  733. data/spec/lib/pact_broker/domain/tag_spec.rb +1 -1
  734. data/spec/lib/pact_broker/domain/verification_spec.rb +3 -3
  735. data/spec/lib/pact_broker/domain/version_spec.rb +118 -7
  736. data/spec/lib/pact_broker/domain/webhook_request_spec.rb +36 -36
  737. data/spec/lib/pact_broker/domain/webhook_spec.rb +11 -11
  738. data/spec/lib/pact_broker/errors/error_logger_spec.rb +4 -4
  739. data/spec/lib/pact_broker/errors_spec.rb +7 -8
  740. data/spec/lib/pact_broker/events/subscriber_spec.rb +43 -0
  741. data/spec/lib/pact_broker/feature_toggle_spec.rb +9 -9
  742. data/spec/lib/pact_broker/groups/service_spec.rb +8 -8
  743. data/spec/lib/pact_broker/hash_refinements_spec.rb +1 -1
  744. data/spec/lib/pact_broker/index/service_spec.rb +13 -14
  745. data/spec/lib/pact_broker/integrations/integration_spec.rb +1 -1
  746. data/spec/lib/pact_broker/integrations/service_spec.rb +17 -6
  747. data/spec/lib/pact_broker/labels/repository_spec.rb +2 -2
  748. data/spec/lib/pact_broker/labels/service_spec.rb +1 -1
  749. data/spec/lib/pact_broker/matrix/aggregated_row_spec.rb +14 -14
  750. data/spec/lib/pact_broker/matrix/can_i_deploy_query_schema_spec.rb +72 -0
  751. data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +100 -20
  752. data/spec/lib/pact_broker/matrix/every_row_spec.rb +5 -5
  753. data/spec/lib/pact_broker/matrix/head_row_spec.rb +1 -1
  754. data/spec/lib/pact_broker/matrix/integration_environment_spec.rb +175 -0
  755. data/spec/lib/pact_broker/matrix/integration_ignore_spec.rb +226 -0
  756. data/spec/lib/pact_broker/matrix/integration_spec.rb +11 -13
  757. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +49 -0
  758. data/spec/lib/pact_broker/matrix/parse_query_spec.rb +28 -6
  759. data/spec/lib/pact_broker/matrix/quick_row_spec.rb +7 -7
  760. data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +2 -2
  761. data/spec/lib/pact_broker/matrix/repository_query_limit_spec.rb +9 -9
  762. data/spec/lib/pact_broker/matrix/repository_spec.rb +44 -211
  763. data/spec/lib/pact_broker/matrix/row_spec.rb +7 -7
  764. data/spec/lib/pact_broker/matrix/service_spec.rb +83 -20
  765. data/spec/lib/pact_broker/messages_spec.rb +6 -6
  766. data/spec/lib/pact_broker/metrics/service_spec.rb +1 -1
  767. data/spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb +10 -10
  768. data/spec/lib/pact_broker/pacticipants/generate_display_name_spec.rb +39 -0
  769. data/spec/lib/pact_broker/pacticipants/repository_spec.rb +86 -15
  770. data/spec/lib/pact_broker/pacticipants/service_spec.rb +27 -73
  771. data/spec/lib/pact_broker/pacts/build_verifiable_pact_notices_spec.rb +10 -10
  772. data/spec/lib/pact_broker/pacts/content_spec.rb +55 -55
  773. data/spec/lib/pact_broker/pacts/create_formatted_diff_spec.rb +10 -10
  774. data/spec/lib/pact_broker/pacts/diff_spec.rb +23 -23
  775. data/spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb +1 -1
  776. data/spec/lib/pact_broker/pacts/generate_sha_spec.rb +7 -7
  777. data/spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb +1 -1
  778. data/spec/lib/pact_broker/pacts/merger_spec.rb +7 -7
  779. data/spec/lib/pact_broker/pacts/metadata_spec.rb +3 -3
  780. data/spec/lib/pact_broker/pacts/pact_params_spec.rb +12 -12
  781. data/spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb +8 -8
  782. data/spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb +120 -0
  783. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +9 -9
  784. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +47 -3
  785. data/spec/lib/pact_broker/pacts/repository_find_for_currently_deployed_spec.rb +124 -0
  786. data/spec/lib/pact_broker/pacts/repository_find_for_currently_supported_releases_spec.rb +159 -0
  787. data/spec/lib/pact_broker/pacts/repository_find_for_verification_fallback_spec.rb +1 -1
  788. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +19 -19
  789. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_branch_spec.rb +59 -1
  790. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +81 -22
  791. data/spec/lib/pact_broker/pacts/repository_spec.rb +39 -39
  792. data/spec/lib/pact_broker/pacts/selected_pact_spec.rb +1 -1
  793. data/spec/lib/pact_broker/pacts/selector_spec.rb +14 -11
  794. data/spec/lib/pact_broker/pacts/selectors_spec.rb +3 -3
  795. data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +5 -5
  796. data/spec/lib/pact_broker/pacts/service_spec.rb +111 -39
  797. data/spec/lib/pact_broker/pacts/sort_content_spec.rb +21 -8
  798. data/spec/lib/pact_broker/pacts/squash_pacts_for_verification_spec.rb +3 -3
  799. data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +99 -35
  800. data/spec/lib/pact_broker/relationships/groupify_spec.rb +12 -12
  801. data/spec/lib/pact_broker/tags/repository_spec.rb +2 -2
  802. data/spec/lib/pact_broker/tags/service_spec.rb +2 -2
  803. data/spec/lib/pact_broker/ui/controllers/can_i_deploy_spec.rb +1 -1
  804. data/spec/lib/pact_broker/ui/controllers/clusters_spec.rb +3 -3
  805. data/spec/lib/pact_broker/ui/controllers/index_spec.rb +47 -8
  806. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +9 -9
  807. data/spec/lib/pact_broker/ui/view_models/index_items_spec.rb +3 -3
  808. data/spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb +29 -0
  809. data/spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb +5 -5
  810. data/spec/lib/pact_broker/verifications/repository_spec.rb +4 -4
  811. data/spec/lib/pact_broker/verifications/sequence_spec.rb +1 -1
  812. data/spec/lib/pact_broker/verifications/service_spec.rb +30 -25
  813. data/spec/lib/pact_broker/verifications/summary_for_consumer_version_spec.rb +6 -6
  814. data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +5 -5
  815. data/spec/lib/pact_broker/versions/parse_semantic_version_spec.rb +2 -2
  816. data/spec/lib/pact_broker/versions/repository_spec.rb +16 -6
  817. data/spec/lib/pact_broker/versions/service_spec.rb +1 -1
  818. data/spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb +1 -1
  819. data/spec/lib/pact_broker/webhooks/execution_configuration_spec.rb +1 -1
  820. data/spec/lib/pact_broker/webhooks/job_spec.rb +10 -10
  821. data/spec/lib/pact_broker/webhooks/pact_and_verification_parameters_spec.rb +16 -0
  822. data/spec/lib/pact_broker/webhooks/redact_logs_spec.rb +1 -1
  823. data/spec/lib/pact_broker/webhooks/render_spec.rb +19 -10
  824. data/spec/lib/pact_broker/webhooks/repository_spec.rb +203 -177
  825. data/spec/lib/pact_broker/webhooks/service_spec.rb +37 -243
  826. data/spec/lib/pact_broker/webhooks/status_spec.rb +5 -5
  827. data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +252 -127
  828. data/spec/lib/pact_broker/webhooks/triggered_webhook_spec.rb +2 -2
  829. data/spec/lib/pact_broker/webhooks/webhook_request_logger_spec.rb +11 -11
  830. data/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +70 -28
  831. data/spec/lib/pact_broker/webhooks/webhook_spec.rb +2 -5
  832. data/spec/lib/rack/hal_browser/redirect_spec.rb +18 -18
  833. data/spec/lib/rack/pact_broker/add_pact_broker_version_header_spec.rb +3 -3
  834. data/spec/lib/rack/pact_broker/database_transaction_spec.rb +10 -15
  835. data/spec/lib/rack/pact_broker/invalid_uri_protection_spec.rb +2 -2
  836. data/spec/lib/rack/pact_broker/request_target_spec.rb +5 -5
  837. data/spec/lib/rack/pact_broker/set_base_url_spec.rb +86 -0
  838. data/spec/lib/rack/pact_broker/use_when_spec.rb +6 -6
  839. data/spec/lib/sequel/plugins/insert_ignore_spec.rb +2 -2
  840. data/spec/lib/sequel/plugins/upsert_spec.rb +3 -3
  841. data/spec/lib/webmachine/rack_adapter_monkey_patch_spec.rb +7 -8
  842. data/spec/migrations/23_pact_versions_spec.rb +11 -13
  843. data/spec/migrations/24_populate_pact_contents_spec.rb +7 -7
  844. data/spec/migrations/34_latest_tagged_pacts_spec.rb +23 -23
  845. data/spec/migrations/34_pact_revisions_spec.rb +10 -10
  846. data/spec/migrations/41_migrate_execution_data_spec.rb +11 -11
  847. data/spec/migrations/42_delete_ophan_webhook_data_spec.rb +17 -17
  848. data/spec/migrations/44_add_provider_version_to_verification_spec.rb +9 -9
  849. data/spec/migrations/50_create_latest_matrix_spec.rb +15 -15
  850. data/spec/migrations/change_migration_strategy_spec.rb +21 -21
  851. data/spec/migrations/rollback_spec.rb +2 -0
  852. data/spec/service_consumers/hal_relation_proxy_app.rb +30 -7
  853. data/spec/service_consumers/pact_helper.rb +24 -11
  854. data/spec/service_consumers/provider_states_for_pact_broker_client.rb +101 -18
  855. data/spec/service_consumers/provider_states_for_pact_broker_client_2.rb +36 -0
  856. data/spec/service_consumers/provider_states_for_pact_ruby.rb +64 -64
  857. data/spec/spec_helper.rb +13 -25
  858. data/spec/support/approvals.rb +9 -7
  859. data/spec/support/database.rb +8 -4
  860. data/spec/support/database_cleaner.rb +2 -2
  861. data/spec/support/fixture_helpers.rb +1 -1
  862. data/spec/support/logging.rb +2 -2
  863. data/spec/support/metadata_test_server.rb +7 -7
  864. data/spec/support/migration_helpers.rb +1 -1
  865. data/spec/support/rack_helpers.rb +20 -0
  866. data/spec/support/rspec_matchers.rb +1 -1
  867. data/spec/support/shared_context.rb +1 -1
  868. data/spec/support/shared_examples_for_responses.rb +15 -4
  869. data/spec/support/simplecov.rb +20 -7
  870. data/spec/support/ssl_pact_broker_server.rb +8 -8
  871. data/spec/support/ssl_webhook_server.rb +8 -8
  872. data/spec/support/test_data_builder.rb +1 -1
  873. data/spec/support/verification_job.rb +8 -8
  874. data/spec/support/webhook_endpoint_middleware.rb +4 -4
  875. data/tasks/audit.rake +1 -1
  876. data/tasks/database.rb +23 -23
  877. data/tasks/database/annotate.rb +2 -2
  878. data/tasks/database/table_dependency_calculator.rb +1 -1
  879. data/tasks/db.rake +34 -39
  880. data/tasks/development.rake +38 -6
  881. data/tasks/docker_database.rb +9 -9
  882. data/tasks/pact.rake +5 -5
  883. data/tasks/release.rake +2 -2
  884. data/tasks/rspec.rake +16 -16
  885. data/tasks/test_db.rake +11 -11
  886. data/vendor/hal-browser/styles.css +6 -0
  887. metadata +209 -21
  888. data/.travis.yml +0 -31
  889. data/lib/pact_broker/domain/webhook_request_header.rb +0 -13
  890. data/lib/webmachine/rack_adapter_monkey_patch.rb +0 -38
  891. data/spec/lib/pact_broker/domain/pacticipant_spec.rb +0 -26
@@ -1,4 +1,4 @@
1
- require 'pact_broker/pacts/repository'
1
+ require "pact_broker/pacts/repository"
2
2
 
3
3
  module PactBroker
4
4
  module Pacts
@@ -218,6 +218,64 @@ module PactBroker
218
218
  expect(subject.size).to be 0
219
219
  end
220
220
  end
221
+
222
+ context "when the provider version tag specified does not exist yet and there are previous successful verifications from another branch" do
223
+ before do
224
+ td.create_pact_with_hierarchy("foo", "1", "bar")
225
+ .create_consumer_version_tag("main")
226
+ .create_verification(provider_version: "20", branch: "dev", success: true)
227
+ .create_verification(provider_version: "21", number: 2)
228
+ end
229
+
230
+ let(:provider_version_branch) { "feat-new-branch" }
231
+
232
+ it { is_expected.to be_empty }
233
+ end
234
+
235
+ context "when the provider version tag specified does not exist yet and there are previous failed verifications from another branch" do
236
+ before do
237
+ td.create_pact_with_hierarchy("foo", "1", "bar")
238
+ .create_consumer_version_tag("main")
239
+ .create_verification(provider_version: "20", branch: "dev", success: false)
240
+ .create_verification(provider_version: "21", number: 2)
241
+ end
242
+
243
+ let(:provider_version_branch) { "feat-new-branch" }
244
+
245
+ it "is included" do
246
+ expect(subject.first.provider_branch).to eq provider_version_branch
247
+ end
248
+ end
249
+
250
+ context "when there is a successful verification from before the first provider version with the specified tag was created" do
251
+ before do
252
+ td.create_pact_with_hierarchy("foo", "1", "bar")
253
+ .create_consumer_version_tag("main")
254
+ .create_verification(provider_version: "20", branch: "dev", success: true)
255
+ .add_day
256
+ .create_verification(provider_version: "21", branch: "feat-new-branch", number: 2, success: false)
257
+ end
258
+
259
+ let(:provider_version_branch) { "feat-new-branch" }
260
+
261
+ it { is_expected.to be_empty }
262
+ end
263
+
264
+ context "when there is a successful verification from after the first provider version with the specified tag was created" do
265
+ before do
266
+ td.create_pact_with_hierarchy("foo", "1", "bar")
267
+ .create_consumer_version_tag("main")
268
+ .create_verification(provider_version: "21", branch: "feat-new-branch", number: 2, success: false)
269
+ .add_day
270
+ .create_verification(provider_version: "20", branch: "dev", success: true)
271
+ end
272
+
273
+ let(:provider_version_branch) { "feat-new-branch" }
274
+
275
+ it "is included" do
276
+ expect(subject.first.provider_branch).to eq provider_version_branch
277
+ end
278
+ end
221
279
  end
222
280
  end
223
281
  end
@@ -1,4 +1,4 @@
1
- require 'pact_broker/pacts/repository'
1
+ require "pact_broker/pacts/repository"
2
2
 
3
3
  module PactBroker
4
4
  module Pacts
@@ -253,24 +253,22 @@ module PactBroker
253
253
  end
254
254
  end
255
255
 
256
- context "when the first provider tag with a given name was created after the head pact was created" do
256
+ context "when the provider tag does not exist yet and there are no provider versions" do
257
257
  before do
258
258
  td.create_pact_with_hierarchy("foo", "1", "bar")
259
259
  .create_consumer_version_tag("feat-x")
260
- .add_day
261
- .create_provider_version("5")
262
- .create_provider_version_tag(provider_tags.first)
263
260
  end
264
261
 
265
- it "doesn't return any pacts" do
266
- expect(subject.size).to be 0
262
+ it "is included" do
263
+ expect(subject.size).to be 1
267
264
  end
268
265
  end
269
266
 
270
- context "when the provider tag does not exist yet and there are no provider versions" do
267
+ context "when the provider tag does not exist yet but there are other provider versions" do
271
268
  before do
272
269
  td.create_pact_with_hierarchy("foo", "1", "bar")
273
270
  .create_consumer_version_tag("feat-x")
271
+ .create_provider_version("1")
274
272
  end
275
273
 
276
274
  it "is included" do
@@ -278,35 +276,96 @@ module PactBroker
278
276
  end
279
277
  end
280
278
 
281
- context "when the provider tag does not exist yet but there are other provider versions" do
279
+ context "when a pact was already successfully verified by another branch before the first creation of one tag but not the other" do
280
+ let(:provider_tags) { %w[dev feat-1] }
281
+
282
282
  before do
283
283
  td.create_pact_with_hierarchy("foo", "1", "bar")
284
284
  .create_consumer_version_tag("feat-x")
285
- .create_provider_version("1")
285
+ .add_day
286
+ .create_verification(provider_version: "1", success: false, number: 1, tag_names: %w[dev])
287
+ .add_day
288
+ .create_verification(provider_version: "2", success: true, number: 2, tag_names: %w[blah])
289
+ .add_day
290
+ .create_verification(provider_version: "3", success: false, number: 3, tag_names: %w[feat-1])
286
291
  end
287
292
 
288
- it "doesn't return any pacts" do
289
- expect(subject.size).to be 0
293
+ it "is wip for the first tag but not the second" do
294
+ expect(subject.first.pending_provider_tags).to eq %w[dev]
290
295
  end
291
296
  end
292
297
 
293
-
294
- context "when a pact was published between the first creation date of two provider tags" do
298
+ context "when a pact was already successfully verified by another branch before the first creation of one tag but not the other" do
295
299
  let(:provider_tags) { %w[dev feat-1] }
296
300
 
297
301
  before do
298
- td.create_provider("bar")
299
- .create_provider_version("4")
300
- .create_provider_version_tag(provider_tags.first)
301
- .add_day
302
- .create_pact_with_hierarchy("foo", "1", "bar")
302
+ td.create_pact_with_hierarchy("foo", "1", "bar")
303
303
  .create_consumer_version_tag("feat-x")
304
304
  .add_day
305
- .create_provider_version("5")
306
- .create_provider_version_tag(provider_tags.last)
305
+ .create_verification(provider_version: "1", success: true, number: 1, tag_names: %w[dev])
306
+ .add_day
307
+ .create_verification(provider_version: "3", success: false, number: 3, tag_names: %w[feat-1])
307
308
  end
308
309
 
309
- it "is wip for the first tag but not the second" do
310
+ it "this should be WIP, as it hasn't been successfully verified by both dev AND feat-1 - need to update logic to exclude previous verifications from other specified tags. But two tags doesn't make sense anyway. Will leave it for now.", pending: true do
311
+ expect(subject).to_not be_empty
312
+ end
313
+ end
314
+
315
+ context "when the provider version tag specified does not exist yet and there are previous successful verifications from another branch" do
316
+ before do
317
+ td.create_pact_with_hierarchy("foo", "1", "bar")
318
+ .create_consumer_version_tag("main")
319
+ .create_verification(provider_version: "20", tag_names: ["dev"], success: true)
320
+ .create_verification(provider_version: "21", number: 2)
321
+ end
322
+
323
+ let(:provider_tags) { %w[feat-new-branch] }
324
+
325
+ it { is_expected.to be_empty }
326
+ end
327
+
328
+ context "when the provider version tag specified does not exist yet and there are previous failed verifications from another branch" do
329
+ before do
330
+ td.create_pact_with_hierarchy("foo", "1", "bar")
331
+ .create_consumer_version_tag("main")
332
+ .create_verification(provider_version: "20", tag_names: ["dev"], success: false)
333
+ .create_verification(provider_version: "21", number: 2)
334
+ end
335
+
336
+ let(:provider_tags) { %w[feat-new-branch] }
337
+
338
+ it "is included" do
339
+ expect(subject.first.pending_provider_tags).to eq [provider_tags.first]
340
+ end
341
+ end
342
+
343
+ context "when there is a successful verification from before the first provider version with the specified tag was created" do
344
+ before do
345
+ td.create_pact_with_hierarchy("foo", "1", "bar")
346
+ .create_consumer_version_tag("main")
347
+ .create_verification(provider_version: "20", tag_names: ["dev"], success: true)
348
+ .add_day
349
+ .create_verification(provider_version: "21", tag_names: ["feat-new-branch"], number: 2, success: false)
350
+ end
351
+
352
+ let(:provider_tags) { %w[feat-new-branch] }
353
+
354
+ it { is_expected.to be_empty }
355
+ end
356
+
357
+ context "when there is a successful verification from after the first provider version with the specified tag was created" do
358
+ before do
359
+ td.create_pact_with_hierarchy("foo", "1", "bar")
360
+ .create_consumer_version_tag("main")
361
+ .create_verification(provider_version: "21", tag_names: ["feat-new-branch"], number: 2, success: false)
362
+ .add_day
363
+ .create_verification(provider_version: "20", tag_names: ["dev"], success: true)
364
+ end
365
+
366
+ let(:provider_tags) { %w[feat-new-branch] }
367
+
368
+ it "is included" do
310
369
  expect(subject.first.pending_provider_tags).to eq [provider_tags.first]
311
370
  end
312
371
  end
@@ -1,23 +1,23 @@
1
1
  # Yes, I know this file is too bug, but cmd+shift+t is too useful!
2
2
 
3
- require 'pact_broker/pacts/repository'
4
- require 'pact_broker/pacts/pact_params'
5
- require 'pact_broker/versions/repository'
6
- require 'pact_broker/pacticipants/repository'
3
+ require "pact_broker/pacts/repository"
4
+ require "pact_broker/pacts/pact_params"
5
+ require "pact_broker/versions/repository"
6
+ require "pact_broker/pacticipants/repository"
7
7
 
8
8
  module PactBroker
9
9
  module Pacts
10
10
  describe Repository do
11
11
 
12
- let(:consumer_name) { 'Consumer' }
13
- let(:provider_name) { 'Provider' }
12
+ let(:consumer_name) { "Consumer" }
13
+ let(:provider_name) { "Provider" }
14
14
 
15
15
  describe "create" do
16
- let(:consumer) { Pacticipants::Repository.new.create name: 'Consumer' }
17
- let(:provider) { Pacticipants::Repository.new.create name: 'Provider' }
18
- let(:version) { PactBroker::Versions::Repository.new.create number: '1.2.3', pacticipant_id: consumer.id }
19
- let(:pact_version_sha) { '123' }
20
- let(:json_content) { {some: 'json'}.to_json }
16
+ let(:consumer) { Pacticipants::Repository.new.create name: "Consumer" }
17
+ let(:provider) { Pacticipants::Repository.new.create name: "Provider" }
18
+ let(:version) { PactBroker::Versions::Repository.new.create number: "1.2.3", pacticipant_id: consumer.id }
19
+ let(:pact_version_sha) { "123" }
20
+ let(:json_content) { {some: "json"}.to_json }
21
21
 
22
22
  let(:params) do
23
23
  {
@@ -47,8 +47,8 @@ module PactBroker
47
47
  it "sets all the Pact::Model attributes" do
48
48
  expect(subject.consumer).to eq consumer
49
49
  expect(subject.provider).to eq provider
50
- expect(subject.consumer_version_number).to eq '1.2.3'
51
- expect(subject.consumer_version.number).to eq '1.2.3'
50
+ expect(subject.consumer_version_number).to eq "1.2.3"
51
+ expect(subject.consumer_version.number).to eq "1.2.3"
52
52
  expect(subject.json_content).to eq json_content
53
53
  expect(subject.created_at).to be_datey
54
54
  end
@@ -63,7 +63,7 @@ module PactBroker
63
63
  end
64
64
 
65
65
  context "when a pact already exists with exactly the same content" do
66
- let(:another_version) { Versions::Repository.new.create number: '2.0.0', pacticipant_id: consumer.id }
66
+ let(:another_version) { Versions::Repository.new.create number: "2.0.0", pacticipant_id: consumer.id }
67
67
 
68
68
  before do
69
69
  Repository.new.create(
@@ -111,9 +111,9 @@ module PactBroker
111
111
  end
112
112
 
113
113
  context "when base_equality_only_on_content_that_affects_verification_results is true" do
114
- let(:another_version) { Versions::Repository.new.create number: '2.0.0', pacticipant_id: consumer.id }
115
- let(:sha_1) { '1' }
116
- let(:sha_2) { '1' }
114
+ let(:another_version) { Versions::Repository.new.create number: "2.0.0", pacticipant_id: consumer.id }
115
+ let(:sha_1) { "1" }
116
+ let(:sha_2) { "1" }
117
117
 
118
118
  before do
119
119
  # PactBroker.configuration.base_equality_only_on_content_that_affects_verification_results = true
@@ -144,7 +144,7 @@ module PactBroker
144
144
  end
145
145
 
146
146
  context "when the sha is not the same" do
147
- let(:sha_2) { '2' }
147
+ let(:sha_2) { "2" }
148
148
 
149
149
  it "creates a new PactVersion" do
150
150
  expect { subject }.to change{ PactVersion.count }.by(1)
@@ -153,8 +153,8 @@ module PactBroker
153
153
  end
154
154
 
155
155
  context "when a pact already exists with the same content but with a different consumer/provider" do
156
- let(:another_version) { Versions::Repository.new.create number: '2.0.0', pacticipant_id: consumer.id }
157
- let(:another_provider) { Pacticipants::Repository.new.create name: 'Provider2' }
156
+ let(:another_version) { Versions::Repository.new.create number: "2.0.0", pacticipant_id: consumer.id }
157
+ let(:another_provider) { Pacticipants::Repository.new.create name: "Provider2" }
158
158
  before do
159
159
  Repository.new.create(
160
160
  version_id: version.id,
@@ -181,14 +181,14 @@ module PactBroker
181
181
  end
182
182
 
183
183
  context "when a pact already exists with different content" do
184
- let(:another_version) { Versions::Repository.new.create number: '2.0.0', pacticipant_id: consumer.id }
184
+ let(:another_version) { Versions::Repository.new.create number: "2.0.0", pacticipant_id: consumer.id }
185
185
 
186
186
  before do
187
187
  Repository.new.create(
188
188
  version_id: version.id,
189
189
  consumer_id: consumer.id,
190
190
  provider_id: provider.id,
191
- json_content: {some_other: 'json_content'}.to_json,
191
+ json_content: {some_other: "json_content"}.to_json,
192
192
  pact_version_sha: pact_version_sha
193
193
  )
194
194
  end
@@ -232,10 +232,10 @@ module PactBroker
232
232
 
233
233
  let(:created_at) { DateTime.new(2014, 3, 2) }
234
234
 
235
- let(:original_json_content) { {some: 'json'}.to_json }
236
- let(:json_content) { {some_other: 'json'}.to_json }
237
- let(:pact_version_sha) { '123' }
238
- let(:new_pact_version_sha) { '567' }
235
+ let(:original_json_content) { {some: "json"}.to_json }
236
+ let(:json_content) { {some_other: "json"}.to_json }
237
+ let(:pact_version_sha) { "123" }
238
+ let(:new_pact_version_sha) { "567" }
239
239
 
240
240
  context "when the pact_version_sha has changed" do
241
241
  subject { repository.update(existing_pact.id, json_content: json_content, pact_version_sha: new_pact_version_sha) }
@@ -325,7 +325,7 @@ module PactBroker
325
325
  .create_pact
326
326
  end
327
327
 
328
- let(:pact_params) { PactBroker::Pacts::PactParams.new(consumer_name: consumer_name, provider_name: provider_name, consumer_version_number: '1.2.3') }
328
+ let(:pact_params) { PactBroker::Pacts::PactParams.new(consumer_name: consumer_name, provider_name: provider_name, consumer_version_number: "1.2.3") }
329
329
 
330
330
  subject { Repository.new.delete pact_params }
331
331
 
@@ -807,18 +807,18 @@ module PactBroker
807
807
 
808
808
  describe "find_previous_distinct_pact" do
809
809
 
810
- let(:pact_content_version_1) { load_fixture('consumer-provider.json') }
810
+ let(:pact_content_version_1) { load_fixture("consumer-provider.json") }
811
811
  let(:pact_content_version_2) do
812
- hash = load_json_fixture('consumer-provider.json')
813
- hash['interactions'].first['foo'] = 'bar' # Extra key in interactions will affect equality
812
+ hash = load_json_fixture("consumer-provider.json")
813
+ hash["interactions"].first["foo"] = "bar" # Extra key in interactions will affect equality
814
814
  hash.to_json
815
815
  end
816
- let(:pact_content_version_3) { load_fixture('consumer-provider.json') }
816
+ let(:pact_content_version_3) { load_fixture("consumer-provider.json") }
817
817
  let(:pact_content_version_4) do
818
818
  # Move description to end of hash, should not affect equality
819
- hash = load_json_fixture('consumer-provider.json')
820
- description = hash['interactions'].first.delete('description')
821
- hash['interactions'].first['description'] = description
819
+ hash = load_json_fixture("consumer-provider.json")
820
+ description = hash["interactions"].first.delete("description")
821
+ hash["interactions"].first["description"] = description
822
822
  hash.to_json
823
823
  end
824
824
 
@@ -851,7 +851,7 @@ module PactBroker
851
851
  end
852
852
 
853
853
  context "when there isn't a previous distinct version" do
854
- let(:pact_content_version_2) { load_fixture('consumer-provider.json') }
854
+ let(:pact_content_version_2) { load_fixture("consumer-provider.json") }
855
855
 
856
856
  it "returns nil" do
857
857
  expect(subject).to be nil
@@ -983,19 +983,19 @@ module PactBroker
983
983
  before do
984
984
  TestDataBuilder.new
985
985
  .create_consumer("Condor")
986
- .create_consumer_version('1.3.0')
986
+ .create_consumer_version("1.3.0")
987
987
  .create_provider("Pricing Service")
988
988
  .create_pact
989
- .create_consumer_version('1.4.0')
989
+ .create_consumer_version("1.4.0")
990
990
  .create_consumer_version_tag("prod")
991
991
  .create_pact
992
992
  .create_consumer("Contract Email Service")
993
993
  .create_consumer_version("2.6.0")
994
994
  .create_provider("Contract Proposal Service")
995
995
  .create_pact
996
- .create_consumer_version('2.7.0')
996
+ .create_consumer_version("2.7.0")
997
997
  .create_pact
998
- .create_consumer_version('2.8.0') # Create a version without a pact, it shouldn't be used
998
+ .create_consumer_version("2.8.0") # Create a version without a pact, it shouldn't be used
999
999
  end
1000
1000
 
1001
1001
  it "finds the latest pact for each consumer/provider pair" do
@@ -1,4 +1,4 @@
1
- require 'pact_broker/pacts/selected_pact'
1
+ require "pact_broker/pacts/selected_pact"
2
2
 
3
3
  module PactBroker
4
4
  module Pacts
@@ -1,4 +1,4 @@
1
- require 'pact_broker/pacts/selector'
1
+ require "pact_broker/pacts/selector"
2
2
 
3
3
  module PactBroker
4
4
  module Pacts
@@ -6,21 +6,24 @@ module PactBroker
6
6
  describe "<=>" do
7
7
  let(:overall_latest_1) { Selector.overall_latest }
8
8
  let(:overall_latest_2) { Selector.overall_latest }
9
- let(:latest_for_branch_main) { Selector.latest_for_branch('main') }
10
- let(:latest_for_tag_prod) { Selector.latest_for_tag('prod') }
11
- let(:latest_for_tag_dev) { Selector.latest_for_tag('dev') }
12
- let(:all_prod_for_consumer_1) { Selector.all_for_tag_and_consumer('prod', 'Foo') }
13
- let(:all_prod_for_consumer_2) { Selector.all_for_tag_and_consumer('prod', 'Bar') }
14
- let(:all_dev_for_consumer_1) { Selector.all_for_tag_and_consumer('dev', 'Bar') }
15
- let(:all_prod) { Selector.all_for_tag('prod') }
16
- let(:all_dev) { Selector.all_for_tag('dev') }
9
+ let(:latest_for_branch_main) { Selector.latest_for_branch("main") }
10
+ let(:latest_for_tag_prod) { Selector.latest_for_tag("prod") }
11
+ let(:latest_for_tag_dev) { Selector.latest_for_tag("dev") }
12
+ let(:all_prod_for_consumer_1) { Selector.all_for_tag_and_consumer("prod", "Foo") }
13
+ let(:all_prod_for_consumer_2) { Selector.all_for_tag_and_consumer("prod", "Bar") }
14
+ let(:all_dev_for_consumer_1) { Selector.all_for_tag_and_consumer("dev", "Bar") }
15
+ let(:all_prod) { Selector.all_for_tag("prod") }
16
+ let(:all_dev) { Selector.all_for_tag("dev") }
17
+ let(:currently_deployed_to_prod) { Selector.for_currently_deployed("prod") }
18
+ let(:currently_deployed_to_test) { Selector.for_currently_deployed("test") }
19
+ let(:currently_supported_in_prod) { Selector.for_currently_supported("prod") }
17
20
 
18
21
  let(:unsorted_selectors) do
19
- [all_prod, all_dev, all_dev_for_consumer_1, latest_for_branch_main, latest_for_tag_prod, overall_latest_1, overall_latest_1, latest_for_tag_dev, all_prod_for_consumer_2, all_prod_for_consumer_1]
22
+ [currently_supported_in_prod, all_prod, all_dev, currently_deployed_to_prod, all_dev_for_consumer_1, latest_for_branch_main, latest_for_tag_prod, currently_deployed_to_test, overall_latest_1, overall_latest_1, latest_for_tag_dev, all_prod_for_consumer_2, all_prod_for_consumer_1]
20
23
  end
21
24
 
22
25
  let(:expected_sorted_selectors) do
23
- [overall_latest_1, overall_latest_1, latest_for_branch_main, latest_for_tag_dev, latest_for_tag_prod, all_dev_for_consumer_1, all_prod_for_consumer_2, all_prod_for_consumer_1, all_dev, all_prod]
26
+ [overall_latest_1, overall_latest_1, latest_for_branch_main, currently_deployed_to_prod, currently_deployed_to_test, currently_supported_in_prod, latest_for_tag_dev, latest_for_tag_prod, all_dev_for_consumer_1, all_prod_for_consumer_2, all_prod_for_consumer_1, all_dev, all_prod]
24
27
  end
25
28
 
26
29
  it "sorts the selectors" do
@@ -1,11 +1,11 @@
1
- require 'pact_broker/pacts/selectors'
2
- require 'pact_broker/pacts/selector'
1
+ require "pact_broker/pacts/selectors"
2
+ require "pact_broker/pacts/selector"
3
3
 
4
4
  module PactBroker
5
5
  module Pacts
6
6
  describe Selectors do
7
7
  let(:selector_1) { Selector.overall_latest }
8
- let(:selector_2) { Selector.latest_for_tag('dev') }
8
+ let(:selector_2) { Selector.latest_for_tag("dev") }
9
9
  let(:selectors_1) { Selectors.new([selector_1]) }
10
10
  let(:selectors_2) { Selectors.new([selector_2]) }
11
11
  let(:selectors_array) { [selectors_1, selectors_2] }