pact_broker 2.85.0 → 2.88.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/trigger_pact_docs_update.yml +22 -0
  3. data/CHANGELOG.md +67 -0
  4. data/DEVELOPER_DOCUMENTATION.md +0 -2
  5. data/db/migrations/20210914_add_labels_to_webhooks.rb +14 -0
  6. data/db/migrations/20210915_add_verified_by_to_verification.rb +6 -0
  7. data/db/migrations/20210929_increase_event_context_column_size.rb +14 -0
  8. data/docker-compose-ci-mysql.yml +1 -0
  9. data/docker-compose-test.yml +2 -0
  10. data/docs/CONFIGURATION.md +255 -66
  11. data/docs/api/WEBHOOKS.md +789 -0
  12. data/docs/configuration.yml +166 -101
  13. data/lib/db.rb +0 -1
  14. data/lib/pact/doc/interaction_view_model.rb +2 -2
  15. data/lib/pact/doc/markdown/consumer_contract_renderer.rb +1 -1
  16. data/lib/pact_broker/api/contracts/configuration.rb +33 -0
  17. data/lib/pact_broker/api/contracts/publish_contracts_schema.rb +35 -16
  18. data/lib/pact_broker/api/contracts/webhook_contract.rb +24 -2
  19. data/lib/pact_broker/api/decorators/matrix_decorator.rb +3 -1
  20. data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -0
  21. data/lib/pact_broker/api/decorators/verification_decorator.rb +9 -3
  22. data/lib/pact_broker/api/decorators/webhook_decorator.rb +27 -4
  23. data/lib/pact_broker/api/pact_broker_urls.rb +30 -6
  24. data/lib/pact_broker/api/resources/all_webhooks.rb +2 -2
  25. data/lib/pact_broker/api/resources/default_base_resource.rb +5 -1
  26. data/lib/pact_broker/api/resources/environment.rb +4 -4
  27. data/lib/pact_broker/api/resources/environments.rb +1 -1
  28. data/lib/pact_broker/api/resources/index.rb +7 -1
  29. data/lib/pact_broker/api/resources/metadata_resource_methods.rb +33 -3
  30. data/lib/pact_broker/api/resources/pact_version.rb +4 -0
  31. data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +1 -1
  32. data/lib/pact_broker/api/resources/publish_contracts.rb +1 -1
  33. data/lib/pact_broker/api/resources/verification.rb +5 -2
  34. data/lib/pact_broker/api/resources/webhook_execution.rb +7 -3
  35. data/lib/pact_broker/api/resources/webhook_execution_methods.rb +23 -17
  36. data/lib/pact_broker/api.rb +6 -0
  37. data/lib/pact_broker/application_context.rb +5 -0
  38. data/lib/pact_broker/config/runtime_configuration.rb +4 -0
  39. data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
  40. data/lib/pact_broker/db/clean.rb +1 -2
  41. data/lib/pact_broker/db/delete_overwritten_data.rb +41 -23
  42. data/lib/pact_broker/deployments/deployed_version.rb +1 -0
  43. data/lib/pact_broker/deployments/deployed_version_service.rb +1 -0
  44. data/lib/pact_broker/deployments/environment_service.rb +7 -2
  45. data/lib/pact_broker/deployments/released_version_service.rb +1 -0
  46. data/lib/pact_broker/doc/controllers/app.rb +1 -0
  47. data/lib/pact_broker/doc/views/can-i-deploy.markdown +2 -1
  48. data/lib/pact_broker/doc/views/index/publish-contracts.markdown +38 -9
  49. data/lib/pact_broker/doc/views/pacticipant/label.markdown +12 -0
  50. data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +7 -7
  51. data/lib/pact_broker/doc/views/webhooks.markdown +17 -0
  52. data/lib/pact_broker/domain/index_item.rb +9 -0
  53. data/lib/pact_broker/domain/pacticipant.rb +4 -0
  54. data/lib/pact_broker/domain/verification.rb +19 -4
  55. data/lib/pact_broker/domain/webhook.rb +5 -5
  56. data/lib/pact_broker/domain/webhook_pacticipant.rb +6 -0
  57. data/lib/pact_broker/index/service.rb +4 -4
  58. data/lib/pact_broker/locale/en.yml +4 -1
  59. data/lib/pact_broker/matrix/head_row.rb +1 -1
  60. data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +5 -3
  61. data/lib/pact_broker/matrix/quick_row.rb +0 -1
  62. data/lib/pact_broker/matrix/repository.rb +0 -1
  63. data/lib/pact_broker/matrix/row.rb +2 -2
  64. data/lib/pact_broker/pacticipants/repository.rb +1 -1
  65. data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +0 -1
  66. data/lib/pact_broker/pacts/metadata.rb +7 -1
  67. data/lib/pact_broker/pacts/pact_publication.rb +7 -0
  68. data/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb +19 -0
  69. data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +30 -2
  70. data/lib/pact_broker/pacts/pact_version.rb +24 -1
  71. data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +5 -4
  72. data/lib/pact_broker/pacts/repository.rb +50 -47
  73. data/lib/pact_broker/pacts/service.rb +5 -5
  74. data/lib/pact_broker/string_refinements.rb +1 -1
  75. data/lib/pact_broker/test/http_test_data_builder.rb +40 -10
  76. data/lib/pact_broker/test/test_data_builder.rb +28 -5
  77. data/lib/pact_broker/ui/helpers/url_helper.rb +12 -0
  78. data/lib/pact_broker/ui/view_models/index_item.rb +15 -1
  79. data/lib/pact_broker/ui/view_models/index_item_branch_head.rb +39 -0
  80. data/lib/pact_broker/ui/view_models/index_item_provider_branch_head.rb +39 -0
  81. data/lib/pact_broker/ui/views/dashboard/show.haml +14 -7
  82. data/lib/pact_broker/verifications/repository.rb +5 -2
  83. data/lib/pact_broker/verifications/service.rb +7 -4
  84. data/lib/pact_broker/version.rb +1 -1
  85. data/lib/pact_broker/versions/abbreviate_number.rb +8 -4
  86. data/lib/pact_broker/versions/branch_head.rb +0 -2
  87. data/lib/pact_broker/versions/branch_version.rb +1 -0
  88. data/lib/pact_broker/versions/repository.rb +0 -1
  89. data/lib/pact_broker/webhooks/event_listener.rb +4 -2
  90. data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +18 -3
  91. data/lib/pact_broker/webhooks/repository.rb +10 -4
  92. data/lib/pact_broker/webhooks/trigger_service.rb +1 -1
  93. data/lib/pact_broker/webhooks/webhook.rb +71 -8
  94. data/lib/webmachine/describe_routes.rb +62 -0
  95. data/public/stylesheets/index.css +5 -0
  96. data/script/data/auto-create-things-for-tags.rb +1 -0
  97. data/script/data/branches.rb +1 -1
  98. data/script/data/contract-published-requiring-verification.rb +0 -1
  99. data/script/data/verify-pact-for-multiple-selectors.rb +30 -0
  100. data/script/docs/generate-api-docs.rb +117 -0
  101. data/script/docs/generate-configuration-docs.rb +24 -3
  102. data/script/docs/regenerate-api-docs.sh +11 -0
  103. data/script/generate-erd +55 -0
  104. data/spec/features/create_webhook_spec.rb +55 -10
  105. data/spec/features/get_pact_spec.rb +2 -3
  106. data/spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_options.approved.json +20 -0
  107. data/spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_post.approved.json +43 -0
  108. data/spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_options.approved.json +20 -0
  109. data/spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_post.approved.json +63 -0
  110. data/spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_get.approved.json +20 -0
  111. data/spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_options.approved.json +20 -0
  112. data/spec/fixtures/approvals/docs_webhooks_pact_webhooks_get.approved.json +45 -0
  113. data/spec/fixtures/approvals/docs_webhooks_pact_webhooks_options.approved.json +20 -0
  114. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_get.approved.json +52 -0
  115. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_options.approved.json +20 -0
  116. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_get.approved.json +32 -0
  117. data/spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_options.approved.json +20 -0
  118. data/spec/fixtures/approvals/docs_webhooks_webhook_get.approved.json +74 -0
  119. data/spec/fixtures/approvals/docs_webhooks_webhook_options.approved.json +20 -0
  120. data/spec/fixtures/approvals/docs_webhooks_webhook_put.approved.json +77 -0
  121. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_get.approved.json +41 -0
  122. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_options.approved.json +20 -0
  123. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_get.approved.json +45 -0
  124. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_options.approved.json +20 -0
  125. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_get.approved.json +41 -0
  126. data/spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_options.approved.json +20 -0
  127. data/spec/fixtures/approvals/docs_webhooks_webhooks_get.approved.json +45 -0
  128. data/spec/fixtures/approvals/docs_webhooks_webhooks_options.approved.json +20 -0
  129. data/spec/fixtures/approvals/docs_webhooks_webhooks_post.approved.json +78 -0
  130. data/spec/fixtures/approvals/docs_webhooks_webhooks_status_get.approved.json +79 -0
  131. data/spec/fixtures/approvals/docs_webhooks_webhooks_status_options.approved.json +20 -0
  132. data/spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json +1 -2
  133. data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +1 -2
  134. data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +1 -2
  135. data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +1 -2
  136. data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +1 -2
  137. data/spec/fixtures/approvals/publish_contract_with_validation_error.approved.json +1 -2
  138. data/spec/fixtures/invalid-publish-contract-body.json +38 -0
  139. data/spec/fixtures/verification.json +4 -0
  140. data/spec/integration/pact_metdata_spec.rb +105 -0
  141. data/spec/integration/webhooks/contract_publication_spec.rb +68 -0
  142. data/spec/integration/webhooks/contract_requiring_verification_published_spec.rb +67 -0
  143. data/spec/integration/webhooks/pact_publication_spec.rb +51 -0
  144. data/spec/integration/webhooks_documentation_spec.rb +348 -0
  145. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +2 -2
  146. data/spec/lib/pact_broker/api/contracts/publish_contracts_schema_spec.rb +13 -0
  147. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +50 -0
  148. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +1 -1
  149. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +15 -7
  150. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +4 -2
  151. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +4 -4
  152. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +18 -0
  153. data/spec/lib/pact_broker/api/resources/triggered_webhook_logs_spec.rb +6 -5
  154. data/spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb +30 -0
  155. data/spec/lib/pact_broker/deployments/environment_service_spec.rb +22 -1
  156. data/spec/lib/pact_broker/domain/webhook_spec.rb +35 -0
  157. data/spec/lib/pact_broker/matrix/head_row_spec.rb +9 -5
  158. data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +13 -0
  159. data/spec/lib/pact_broker/pacts/{latest_tagged_pact_publications_spec.rb → pact_publication_clean_selector_dataset_module_spec.rb} +7 -9
  160. data/spec/lib/pact_broker/pacts/pact_version_spec.rb +32 -0
  161. data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +4 -5
  162. data/spec/lib/pact_broker/pacts/repository_spec.rb +33 -0
  163. data/spec/lib/pact_broker/ui/view_models/index_item_spec.rb +1 -1
  164. data/spec/lib/pact_broker/verifications/service_spec.rb +22 -8
  165. data/spec/lib/pact_broker/versions/abbreviate_number_spec.rb +2 -1
  166. data/spec/lib/pact_broker/webhooks/render_spec.rb +3 -2
  167. data/spec/lib/pact_broker/webhooks/repository_spec.rb +158 -15
  168. data/spec/lib/pact_broker/webhooks/webhook_spec.rb +8 -5
  169. data/spec/support/documentation.rb +64 -0
  170. data/spec/support/rack_helpers.rb +1 -1
  171. data/tasks/db.rake +4 -1
  172. data/tasks/development.rake +14 -13
  173. metadata +89 -12
  174. data/lib/pact_broker/pacts/all_pact_publications.rb +0 -158
  175. data/lib/pact_broker/pacts/latest_pact_publications.rb +0 -48
  176. data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +0 -26
  177. data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +0 -45
  178. data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +0 -39
  179. data/spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb +0 -18
@@ -6,6 +6,7 @@ module PactBroker
6
6
  before do
7
7
  td.create_consumer("Foo")
8
8
  .create_provider("Bar")
9
+ .create_label("label1")
9
10
  .create_consumer_version
10
11
  .create_pact
11
12
  .create_global_webhook
@@ -13,11 +14,13 @@ module PactBroker
13
14
  .create_provider_webhook
14
15
  .create_provider("Wiffle")
15
16
  .create_provider_webhook
17
+ .create_webhook(provider: nil, consumer: nil, provider_label: "label1")
18
+ .create_webhook(provider: nil, consumer: nil, consumer_label: "label2", provider_label: "label1")
16
19
  end
17
20
 
18
21
  let(:consumer) { PactBroker::Domain::Pacticipant.find(name: "Foo") }
19
22
  let(:provider) { PactBroker::Domain::Pacticipant.find(name: "Bar") }
20
- let(:pact) { double(consumer_id: consumer.id, provider_id: provider.id).as_null_object }
23
+ let(:pact) { PactBroker::Pacts::PactPublication.find(id: td.pact.id) }
21
24
 
22
25
  describe "#is_for?" do
23
26
  let(:matching_webhook_uuids) { Webhooks::Webhook.find_by_consumer_and_or_provider(consumer, provider).collect(&:uuid) }
@@ -25,10 +28,10 @@ module PactBroker
25
28
  let(:non_matching_webhooks) { Webhooks::Webhook.exclude(uuid: matching_webhook_uuids) }
26
29
 
27
30
  it "matches the implementation of Webhook::Repository#find_by_consumer_and_or_provider" do
28
- expect(matching_webhooks.count).to be > 0
29
- expect(non_matching_webhooks.count).to be > 0
30
- expect(matching_webhooks.all?{|w| w.is_for?(pact)}).to be true
31
- expect(non_matching_webhooks.all?{|w| !w.is_for?(pact)}).to be true
31
+ expect(matching_webhooks).not_to be_empty
32
+ expect(non_matching_webhooks).not_to be_empty
33
+ expect(matching_webhooks.reject{|w| w.is_for?(pact)}).to be_empty
34
+ expect(non_matching_webhooks.reject{|w| !w.is_for?(pact)}).to be_empty
32
35
  end
33
36
  end
34
37
  end
@@ -0,0 +1,64 @@
1
+ module PactBroker
2
+ module Documentation
3
+
4
+ def remove_deprecated_links(thing)
5
+ case thing
6
+ when Hash then remove_deprecated_links_from_hash(thing)
7
+ when Array then thing.collect { |value| remove_deprecated_links(value) }
8
+ else thing
9
+ end
10
+ end
11
+
12
+ def remove_deprecated_links_from_hash(body)
13
+ body.each_with_object({}) do | (key, value), new_body |
14
+ if key == "_links"
15
+ links = value.select do | link_key, _value |
16
+ link_key.start_with?("pb:", "self", "next", "previous", "curies")
17
+ end
18
+ new_body["_links"] = links
19
+ else
20
+ new_body[key] = remove_deprecated_links(value)
21
+ end
22
+ end
23
+ end
24
+
25
+ def build_approval_name(category, example_name, http_method)
26
+ "docs_#{category}_" + example_name.tr(" ", "_") + "_" + http_method
27
+ end
28
+
29
+ def build_path(path_template, parameter_values, custom_parameter_values)
30
+ parameter_values.merge(custom_parameter_values).inject(path_template) do | new_path, (name, value) |
31
+ new_path.gsub(/:#{name}(\/|$)/, value + '\1')
32
+ end
33
+ end
34
+
35
+ def expected_interaction(response, order)
36
+ expectated_body = response.headers["Content-Type"]&.include?("json") && response.body && response.body != "" ? remove_deprecated_links(JSON.parse(response.body)) : response.body
37
+ expected_response = {
38
+ status: response.status,
39
+ headers: determinate_headers(response.headers),
40
+ body: expectated_body
41
+ }
42
+ request = {
43
+ method: http_method,
44
+ path_template: path_template,
45
+ path: path,
46
+ headers: rack_env_to_http_headers(rack_headers),
47
+ body: http_params.is_a?(String) ? JSON.parse(http_params) : nil
48
+ }.compact
49
+
50
+ {
51
+ category: category,
52
+ name: pact_broker_example_name,
53
+ order: order,
54
+ request: request,
55
+ response: expected_response
56
+ }
57
+ end
58
+
59
+ end
60
+ end
61
+
62
+ RSpec.configure do | config |
63
+ config.include(PactBroker::Documentation)
64
+ end
@@ -7,7 +7,7 @@ module PactBroker
7
7
  using PactBroker::StringRefinements
8
8
 
9
9
  def determinate_headers(headers)
10
- headers.without("Date", "Server")
10
+ headers.without("Date", "Server", "Content-Length")
11
11
  end
12
12
 
13
13
  def rack_env_to_http_headers(rack_env)
data/tasks/db.rake CHANGED
@@ -95,7 +95,10 @@ namespace :db do
95
95
  PactBroker::Database.ensure_database_dir_exists
96
96
  end
97
97
 
98
- desc "Annotate the Sequel domain classes with schema information - start the postgres db with script/docker/db-start.sh first"
98
+ desc "Annotate the Sequel domain classes with schema information.
99
+ Start the postgres db with script/docker/db-start.sh first and run
100
+ INSTALL_PG=true bundle exec rake db:annotate
101
+ "
99
102
  task :annotate do
100
103
  begin
101
104
  raise "Need to set INSTALL_PG=true" unless ENV["INSTALL_PG"] == "true"
@@ -18,12 +18,17 @@ task "pact_broker:dev:setup" do
18
18
  end
19
19
 
20
20
  desc "List the Pact Broker API routes"
21
- task "pact_broker:routes", [:search_term] do | _, args |
22
- puts "Listing routes containing the term '#{args[:search_term]}'" if args[:search_term]
21
+ task :'pact_broker:routes', [:search_term] do | _t, args |
22
+ project_root = File.absolute_path(File.join(__dir__, "..", "..", ".."))
23
+ $LOAD_PATH << File.join(project_root,"app_shared","lib")
24
+
25
+ search_term = args[:search_term]
26
+ puts "Listing Pact Broker routes containing the term '#{search_term}'" if search_term
23
27
  require "tempfile"
24
28
  require "sequel"
25
29
  require "pact_broker"
26
30
  require "pact_broker/project_root"
31
+ require "pathname"
27
32
 
28
33
  Tempfile.create("pact_broker_routes") do |f|
29
34
  CONNECTION = Sequel.connect({ adapter: "sqlite", database: f.path, encoding: "utf8", sql_log_level: :debug })
@@ -32,20 +37,16 @@ task "pact_broker:routes", [:search_term] do | _, args |
32
37
  PactBroker::DB.run_migrations(CONNECTION)
33
38
 
34
39
  require "pact_broker/api"
40
+ require "webmachine/describe_routes"
35
41
 
36
- routes_debugging = PactBroker::API.application.routes.collect do | route |
37
- ["/" + route.path_spec.collect{ |part| part.is_a?(Symbol) ? ":#{part}" : part }.join("/"), route.resource]
38
- end
39
-
40
- if args[:search_term]
41
- routes_debugging = routes_debugging.select{ |(route, _)| route.include?(args[:search_term]) }
42
- end
42
+ routes = Webmachine::DescribeRoutes.call([PactBroker::API.application], search_term: search_term)
43
43
 
44
- routes_debugging.sort_by(&:first).each do | (path, resource_class) |
44
+ routes.each do | route |
45
45
  puts ""
46
- puts "#{path}"
47
- puts " class: #{resource_class}"
48
- puts " location: #{resource_class.instance_method(:allowed_methods).source_location.first.gsub(PactBroker.project_root.to_s + "/", "")}"
46
+ puts "#{route[:path]}"
47
+ puts " allowed_methods: #{route[:allowed_methods].join(", ")}"
48
+ puts " class: #{route[:resource_class]}"
49
+ puts " location: #{route[:resource_class_location]}"
49
50
  end
50
51
  end
51
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.85.0
4
+ version: 2.88.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-14 00:00:00.000000000 Z
13
+ date: 2021-10-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -425,6 +425,7 @@ files:
425
425
  - ".github/workflows/release_gem.yml"
426
426
  - ".github/workflows/test-ruby-3.yml"
427
427
  - ".github/workflows/test.yml"
428
+ - ".github/workflows/trigger_pact_docs_update.yml"
428
429
  - ".gitignore"
429
430
  - ".optic/.gitignore"
430
431
  - ".optic/api/specification.json"
@@ -611,6 +612,9 @@ files:
611
612
  - db/migrations/20210831_add_index_to_pact_publications.rb
612
613
  - db/migrations/20210908_add_auto_created.rb
613
614
  - db/migrations/20210913_add_pending_to_verifications.rb
615
+ - db/migrations/20210914_add_labels_to_webhooks.rb
616
+ - db/migrations/20210915_add_verified_by_to_verification.rb
617
+ - db/migrations/20210929_increase_event_context_column_size.rb
614
618
  - db/migrations/migration_helper.rb
615
619
  - db/test/backwards_compatibility/.rspec
616
620
  - db/test/backwards_compatibility/Appraisals
@@ -647,6 +651,7 @@ files:
647
651
  - docker-compose-issue-repro-with-pact-broker-docker-image.yml
648
652
  - docker-compose-test.yml
649
653
  - docs/CONFIGURATION.md
654
+ - docs/api/WEBHOOKS.md
650
655
  - docs/configuration.yml
651
656
  - docs/images/Pactflow logo - black small.png
652
657
  - example/Gemfile
@@ -672,6 +677,7 @@ files:
672
677
  - lib/pact_broker/api/authorization/resource_access_policy.rb
673
678
  - lib/pact_broker/api/authorization/resource_access_rules.rb
674
679
  - lib/pact_broker/api/contracts/base_contract.rb
680
+ - lib/pact_broker/api/contracts/configuration.rb
675
681
  - lib/pact_broker/api/contracts/dry_validation_predicates.rb
676
682
  - lib/pact_broker/api/contracts/dry_validation_workarounds.rb
677
683
  - lib/pact_broker/api/contracts/environment_schema.rb
@@ -932,6 +938,7 @@ files:
932
938
  - lib/pact_broker/doc/views/pact/tag-prod-version.markdown
933
939
  - lib/pact_broker/doc/views/pact/tag-version.markdown
934
940
  - lib/pact_broker/doc/views/pacticipant/can-i-deploy-badge.markdown
941
+ - lib/pact_broker/doc/views/pacticipant/label.markdown
935
942
  - lib/pact_broker/doc/views/pacticipant/versions.markdown
936
943
  - lib/pact_broker/doc/views/pending-provider-pacts.markdown
937
944
  - lib/pact_broker/doc/views/provider-pacts-for-verification.markdown
@@ -949,6 +956,7 @@ files:
949
956
  - lib/pact_broker/domain/verification.rb
950
957
  - lib/pact_broker/domain/version.rb
951
958
  - lib/pact_broker/domain/webhook.rb
959
+ - lib/pact_broker/domain/webhook_pacticipant.rb
952
960
  - lib/pact_broker/domain/webhook_request.rb
953
961
  - lib/pact_broker/error.rb
954
962
  - lib/pact_broker/errors.rb
@@ -995,7 +1003,6 @@ files:
995
1003
  - lib/pact_broker/pacticipants/generate_display_name.rb
996
1004
  - lib/pact_broker/pacticipants/repository.rb
997
1005
  - lib/pact_broker/pacticipants/service.rb
998
- - lib/pact_broker/pacts/all_pact_publications.rb
999
1006
  - lib/pact_broker/pacts/build_verifiable_pact_notices.rb
1000
1007
  - lib/pact_broker/pacts/content.rb
1001
1008
  - lib/pact_broker/pacts/create_formatted_diff.rb
@@ -1005,15 +1012,13 @@ files:
1005
1012
  - lib/pact_broker/pacts/generate_sha.rb
1006
1013
  - lib/pact_broker/pacts/head_pact.rb
1007
1014
  - lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb
1008
- - lib/pact_broker/pacts/latest_pact_publications.rb
1009
- - lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb
1010
- - lib/pact_broker/pacts/latest_tagged_pact_publications.rb
1011
1015
  - lib/pact_broker/pacts/lazy_loaders.rb
1012
1016
  - lib/pact_broker/pacts/merger.rb
1013
1017
  - lib/pact_broker/pacts/metadata.rb
1014
1018
  - lib/pact_broker/pacts/order_hash_keys.rb
1015
1019
  - lib/pact_broker/pacts/pact_params.rb
1016
1020
  - lib/pact_broker/pacts/pact_publication.rb
1021
+ - lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb
1017
1022
  - lib/pact_broker/pacts/pact_publication_dataset_module.rb
1018
1023
  - lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb
1019
1024
  - lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb
@@ -1066,6 +1071,8 @@ files:
1066
1071
  - lib/pact_broker/ui/helpers/url_helper.rb
1067
1072
  - lib/pact_broker/ui/view_models/clusters.rb
1068
1073
  - lib/pact_broker/ui/view_models/index_item.rb
1074
+ - lib/pact_broker/ui/view_models/index_item_branch_head.rb
1075
+ - lib/pact_broker/ui/view_models/index_item_provider_branch_head.rb
1069
1076
  - lib/pact_broker/ui/view_models/index_items.rb
1070
1077
  - lib/pact_broker/ui/view_models/matrix_branch.rb
1071
1078
  - lib/pact_broker/ui/view_models/matrix_deployed_version.rb
@@ -1087,7 +1094,6 @@ files:
1087
1094
  - lib/pact_broker/ui/views/matrix/show.haml
1088
1095
  - lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb
1089
1096
  - lib/pact_broker/verifications/latest_verification_for_consumer_version_tag.rb
1090
- - lib/pact_broker/verifications/latest_verification_for_pact_version.rb
1091
1097
  - lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb
1092
1098
  - lib/pact_broker/verifications/placeholder_verification.rb
1093
1099
  - lib/pact_broker/verifications/pseudo_branch_status.rb
@@ -1151,6 +1157,7 @@ files:
1151
1157
  - lib/sequel/extensions/statement_timeout.rb
1152
1158
  - lib/sequel/plugins/insert_ignore.rb
1153
1159
  - lib/sequel/plugins/upsert.rb
1160
+ - lib/webmachine/describe_routes.rb
1154
1161
  - optic.yml
1155
1162
  - pact_broker.gemspec
1156
1163
  - pact_broker_client-pact_broker.json
@@ -1248,6 +1255,7 @@ files:
1248
1255
  - script/data/issue-494.rb
1249
1256
  - script/data/pending.rb
1250
1257
  - script/data/tags.rb
1258
+ - script/data/verify-pact-for-multiple-selectors.rb
1251
1259
  - script/data/webhook.rb
1252
1260
  - script/db-spec.sh
1253
1261
  - script/demonstrate-version-branches.rb
@@ -1261,11 +1269,14 @@ files:
1261
1269
  - script/docker/db-rm.sh
1262
1270
  - script/docker/db-start.sh
1263
1271
  - script/docker/mysql-db-start.sh
1272
+ - script/docs/generate-api-docs.rb
1264
1273
  - script/docs/generate-configuration-docs.rb
1274
+ - script/docs/regenerate-api-docs.sh
1265
1275
  - script/exercise-api-for-optic.sh
1266
1276
  - script/foo-bar-verification.json
1267
1277
  - script/foo-bar.json
1268
1278
  - script/generate-certificates-for-webooks-certificate-spec.rb
1279
+ - script/generate-erd
1269
1280
  - script/import-pg-database.sh
1270
1281
  - script/insert-self-signed-certificate-from-url.rb
1271
1282
  - script/issues/consumer-version-selectors-docs/issue-text.txt
@@ -1389,6 +1400,32 @@ files:
1389
1400
  - spec/fixtures/a_consumer-a_provider-merged.json
1390
1401
  - spec/fixtures/a_consumer-a_provider.json
1391
1402
  - spec/fixtures/approvals/clean_incremental_dry_run.approved.json
1403
+ - spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_options.approved.json
1404
+ - spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_post.approved.json
1405
+ - spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_options.approved.json
1406
+ - spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_post.approved.json
1407
+ - spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_get.approved.json
1408
+ - spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_options.approved.json
1409
+ - spec/fixtures/approvals/docs_webhooks_pact_webhooks_get.approved.json
1410
+ - spec/fixtures/approvals/docs_webhooks_pact_webhooks_options.approved.json
1411
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_get.approved.json
1412
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_options.approved.json
1413
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_get.approved.json
1414
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_options.approved.json
1415
+ - spec/fixtures/approvals/docs_webhooks_webhook_get.approved.json
1416
+ - spec/fixtures/approvals/docs_webhooks_webhook_options.approved.json
1417
+ - spec/fixtures/approvals/docs_webhooks_webhook_put.approved.json
1418
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_get.approved.json
1419
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_options.approved.json
1420
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_get.approved.json
1421
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_options.approved.json
1422
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_get.approved.json
1423
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_options.approved.json
1424
+ - spec/fixtures/approvals/docs_webhooks_webhooks_get.approved.json
1425
+ - spec/fixtures/approvals/docs_webhooks_webhooks_options.approved.json
1426
+ - spec/fixtures/approvals/docs_webhooks_webhooks_post.approved.json
1427
+ - spec/fixtures/approvals/docs_webhooks_webhooks_status_get.approved.json
1428
+ - spec/fixtures/approvals/docs_webhooks_webhooks_status_options.approved.json
1392
1429
  - spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json
1393
1430
  - spec/fixtures/approvals/matrix_integration_environment_spec.approved.json
1394
1431
  - spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json
@@ -1410,6 +1447,7 @@ files:
1410
1447
  - spec/fixtures/dashboard.json
1411
1448
  - spec/fixtures/expected.gv
1412
1449
  - spec/fixtures/foo-bar.json
1450
+ - spec/fixtures/invalid-publish-contract-body.json
1413
1451
  - spec/fixtures/renderer_pact.json
1414
1452
  - spec/fixtures/update_pacticipant.json
1415
1453
  - spec/fixtures/updated_pacticipant.json
@@ -1418,9 +1456,14 @@ files:
1418
1456
  - spec/fixtures/webhook_valid_with_pacticipants.json
1419
1457
  - spec/integration/app_spec.rb
1420
1458
  - spec/integration/endpoints/group_spec.rb
1459
+ - spec/integration/pact_metdata_spec.rb
1421
1460
  - spec/integration/ui/index_spec.rb
1422
1461
  - spec/integration/ui/matrix_spec.rb
1423
1462
  - spec/integration/webhooks/certificate_spec.rb
1463
+ - spec/integration/webhooks/contract_publication_spec.rb
1464
+ - spec/integration/webhooks/contract_requiring_verification_published_spec.rb
1465
+ - spec/integration/webhooks/pact_publication_spec.rb
1466
+ - spec/integration/webhooks_documentation_spec.rb
1424
1467
  - spec/lib/pact/doc/generator_spec.rb
1425
1468
  - spec/lib/pact/doc/interaction_view_model_spec.rb
1426
1469
  - spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
@@ -1512,6 +1555,7 @@ files:
1512
1555
  - spec/lib/pact_broker/build_http_options_spec.rb
1513
1556
  - spec/lib/pact_broker/certificates/service_spec.rb
1514
1557
  - spec/lib/pact_broker/config/load_spec.rb
1558
+ - spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb
1515
1559
  - spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
1516
1560
  - spec/lib/pact_broker/config/runtime_configuration_spec.rb
1517
1561
  - spec/lib/pact_broker/config/save_spec.rb
@@ -1588,10 +1632,10 @@ files:
1588
1632
  - spec/lib/pact_broker/pacts/diff_spec.rb
1589
1633
  - spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
1590
1634
  - spec/lib/pact_broker/pacts/generate_sha_spec.rb
1591
- - spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb
1592
1635
  - spec/lib/pact_broker/pacts/merger_spec.rb
1593
1636
  - spec/lib/pact_broker/pacts/metadata_spec.rb
1594
1637
  - spec/lib/pact_broker/pacts/pact_params_spec.rb
1638
+ - spec/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module_spec.rb
1595
1639
  - spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb
1596
1640
  - spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb
1597
1641
  - spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb
@@ -1622,7 +1666,6 @@ files:
1622
1666
  - spec/lib/pact_broker/ui/view_models/index_items_spec.rb
1623
1667
  - spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb
1624
1668
  - spec/lib/pact_broker/ui/view_models/matrix_line_spec.rb
1625
- - spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb
1626
1669
  - spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb
1627
1670
  - spec/lib/pact_broker/verifications/repository_spec.rb
1628
1671
  - spec/lib/pact_broker/verifications/sequence_spec.rb
@@ -1679,6 +1722,7 @@ files:
1679
1722
  - spec/support/approvals.rb
1680
1723
  - spec/support/database.rb
1681
1724
  - spec/support/database_cleaner.rb
1725
+ - spec/support/documentation.rb
1682
1726
  - spec/support/fixture_helpers.rb
1683
1727
  - spec/support/fixture_pact.rb
1684
1728
  - spec/support/foo-bar.json
@@ -1775,7 +1819,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1775
1819
  - !ruby/object:Gem::Version
1776
1820
  version: '0'
1777
1821
  requirements: []
1778
- rubygems_version: 3.2.27
1822
+ rubygems_version: 3.2.29
1779
1823
  signing_key:
1780
1824
  specification_version: 4
1781
1825
  summary: See description
@@ -1867,6 +1911,32 @@ test_files:
1867
1911
  - spec/fixtures/a_consumer-a_provider-merged.json
1868
1912
  - spec/fixtures/a_consumer-a_provider.json
1869
1913
  - spec/fixtures/approvals/clean_incremental_dry_run.approved.json
1914
+ - spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_options.approved.json
1915
+ - spec/fixtures/approvals/docs_webhooks_executing_a_saved_webhook_post.approved.json
1916
+ - spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_options.approved.json
1917
+ - spec/fixtures/approvals/docs_webhooks_executing_an_unsaved_webhook_post.approved.json
1918
+ - spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_get.approved.json
1919
+ - spec/fixtures/approvals/docs_webhooks_logs_of_triggered_webhook_options.approved.json
1920
+ - spec/fixtures/approvals/docs_webhooks_pact_webhooks_get.approved.json
1921
+ - spec/fixtures/approvals/docs_webhooks_pact_webhooks_options.approved.json
1922
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_get.approved.json
1923
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_pact_publication_options.approved.json
1924
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_get.approved.json
1925
+ - spec/fixtures/approvals/docs_webhooks_triggered_webhooks_for_verification_publication_options.approved.json
1926
+ - spec/fixtures/approvals/docs_webhooks_webhook_get.approved.json
1927
+ - spec/fixtures/approvals/docs_webhooks_webhook_options.approved.json
1928
+ - spec/fixtures/approvals/docs_webhooks_webhook_put.approved.json
1929
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_get.approved.json
1930
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_a_provider_options.approved.json
1931
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_get.approved.json
1932
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_and_provider_options.approved.json
1933
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_get.approved.json
1934
+ - spec/fixtures/approvals/docs_webhooks_webhooks_for_consumer_options.approved.json
1935
+ - spec/fixtures/approvals/docs_webhooks_webhooks_get.approved.json
1936
+ - spec/fixtures/approvals/docs_webhooks_webhooks_options.approved.json
1937
+ - spec/fixtures/approvals/docs_webhooks_webhooks_post.approved.json
1938
+ - spec/fixtures/approvals/docs_webhooks_webhooks_status_get.approved.json
1939
+ - spec/fixtures/approvals/docs_webhooks_webhooks_status_options.approved.json
1870
1940
  - spec/fixtures/approvals/get_provider_pacts_for_verification.approved.json
1871
1941
  - spec/fixtures/approvals/matrix_integration_environment_spec.approved.json
1872
1942
  - spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json
@@ -1888,6 +1958,7 @@ test_files:
1888
1958
  - spec/fixtures/dashboard.json
1889
1959
  - spec/fixtures/expected.gv
1890
1960
  - spec/fixtures/foo-bar.json
1961
+ - spec/fixtures/invalid-publish-contract-body.json
1891
1962
  - spec/fixtures/renderer_pact.json
1892
1963
  - spec/fixtures/update_pacticipant.json
1893
1964
  - spec/fixtures/updated_pacticipant.json
@@ -1896,9 +1967,14 @@ test_files:
1896
1967
  - spec/fixtures/webhook_valid_with_pacticipants.json
1897
1968
  - spec/integration/app_spec.rb
1898
1969
  - spec/integration/endpoints/group_spec.rb
1970
+ - spec/integration/pact_metdata_spec.rb
1899
1971
  - spec/integration/ui/index_spec.rb
1900
1972
  - spec/integration/ui/matrix_spec.rb
1901
1973
  - spec/integration/webhooks/certificate_spec.rb
1974
+ - spec/integration/webhooks/contract_publication_spec.rb
1975
+ - spec/integration/webhooks/contract_requiring_verification_published_spec.rb
1976
+ - spec/integration/webhooks/pact_publication_spec.rb
1977
+ - spec/integration/webhooks_documentation_spec.rb
1902
1978
  - spec/lib/pact/doc/generator_spec.rb
1903
1979
  - spec/lib/pact/doc/interaction_view_model_spec.rb
1904
1980
  - spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
@@ -1990,6 +2066,7 @@ test_files:
1990
2066
  - spec/lib/pact_broker/build_http_options_spec.rb
1991
2067
  - spec/lib/pact_broker/certificates/service_spec.rb
1992
2068
  - spec/lib/pact_broker/config/load_spec.rb
2069
+ - spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb
1993
2070
  - spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
1994
2071
  - spec/lib/pact_broker/config/runtime_configuration_spec.rb
1995
2072
  - spec/lib/pact_broker/config/save_spec.rb
@@ -2066,10 +2143,10 @@ test_files:
2066
2143
  - spec/lib/pact_broker/pacts/diff_spec.rb
2067
2144
  - spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
2068
2145
  - spec/lib/pact_broker/pacts/generate_sha_spec.rb
2069
- - spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb
2070
2146
  - spec/lib/pact_broker/pacts/merger_spec.rb
2071
2147
  - spec/lib/pact_broker/pacts/metadata_spec.rb
2072
2148
  - spec/lib/pact_broker/pacts/pact_params_spec.rb
2149
+ - spec/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module_spec.rb
2073
2150
  - spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb
2074
2151
  - spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb
2075
2152
  - spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb
@@ -2100,7 +2177,6 @@ test_files:
2100
2177
  - spec/lib/pact_broker/ui/view_models/index_items_spec.rb
2101
2178
  - spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb
2102
2179
  - spec/lib/pact_broker/ui/view_models/matrix_line_spec.rb
2103
- - spec/lib/pact_broker/verifications/latest_verification_for_pact_version_spec.rb
2104
2180
  - spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb
2105
2181
  - spec/lib/pact_broker/verifications/repository_spec.rb
2106
2182
  - spec/lib/pact_broker/verifications/sequence_spec.rb
@@ -2157,6 +2233,7 @@ test_files:
2157
2233
  - spec/support/approvals.rb
2158
2234
  - spec/support/database.rb
2159
2235
  - spec/support/database_cleaner.rb
2236
+ - spec/support/documentation.rb
2160
2237
  - spec/support/fixture_helpers.rb
2161
2238
  - spec/support/fixture_pact.rb
2162
2239
  - spec/support/foo-bar.json
@@ -1,158 +0,0 @@
1
- require "forwardable"
2
- require "pact_broker/domain/tag"
3
- require "pact_broker/domain/pacticipant"
4
- require "pact_broker/domain/version"
5
- require "pact_broker/pacts/pact_version"
6
- require "pact_broker/repositories/helpers"
7
-
8
- module PactBroker
9
- module Pacts
10
- class AllPactPublications < Sequel::Model(:all_pact_publications)
11
-
12
- extend Forwardable
13
-
14
- def_delegators :cached_domain, :name
15
-
16
- set_primary_key :id
17
- associate(:one_to_many, :tags, :class => "PactBroker::Domain::Tag", :reciprocal => :version, :key => :version_id, :primary_key => :consumer_version_id)
18
- associate(:many_to_one, :pact_version, :key => :pact_version_id, :primary_key => :id)
19
- associate(:many_to_one, :latest_verification, :class => "PactBroker::Verifications::LatestVerificationForPactVersion", key: :pact_version_id, primary_key: :pact_version_id)
20
- associate(:many_to_one, :consumer_version, :class => "PactBroker::Domain::Version", :key => :consumer_version_id, :primary_key => :id)
21
-
22
- dataset_module do
23
- include PactBroker::Repositories::Helpers
24
-
25
- def consumer consumer_name
26
- where(name_like(:consumer_name, consumer_name))
27
- end
28
-
29
- def provider provider_name
30
- where(name_like(:provider_name, provider_name))
31
- end
32
-
33
- # must be exactly correct names
34
- def pacticipants pacticipant_1, pacticipant_2
35
- where(
36
- consumer_name: pacticipant_1,
37
- provider_name: pacticipant_2
38
- ).or(
39
- consumer_name: pacticipant_2,
40
- provider_name: pacticipant_1
41
- )
42
- end
43
-
44
- def tag tag_name
45
- filter = name_like(Sequel.qualify(:tags, :name), tag_name)
46
- join(:tags, {version_id: :consumer_version_id}).where(filter)
47
- end
48
-
49
- def untagged
50
- left_outer_join(:tags, {version_id: :consumer_version_id})
51
- .where(Sequel.qualify(:tags, :name) => nil)
52
- end
53
-
54
- def consumer_version_number number
55
- where(name_like(:consumer_version_number, number))
56
- end
57
-
58
- def maybe_consumer_version_number number
59
- if number
60
- where(name_like(:consumer_version_number, number))
61
- else
62
- self
63
- end
64
- end
65
-
66
- def revision_number number
67
- where(revision_number: number)
68
- end
69
-
70
- def pact_version_sha sha
71
- where(pact_version_sha: sha)
72
- end
73
-
74
- def consumer_version_order_before order
75
- where(Sequel.lit("consumer_version_order < ?", order))
76
- end
77
-
78
- def consumer_version_order_after order
79
- where(Sequel.lit("consumer_version_order > ?", order))
80
- end
81
-
82
- def latest
83
- reverse_order(:consumer_version_order).limit(1)
84
- end
85
-
86
- def earliest
87
- order(:consumer_version_order).limit(1)
88
- end
89
- end
90
-
91
- def to_domain
92
- domain = to_domain_without_tags
93
- domain.consumer_version.tags = tags.sort
94
- domain
95
- end
96
-
97
- def to_domain_without_tags
98
- consumer = Domain::Pacticipant.new(name: consumer_name)
99
- consumer.id = consumer_id
100
- provider = Domain::Pacticipant.new(name: provider_name)
101
- provider.id = provider_id
102
- consumer_version_struct = OpenStruct.new(
103
- id: consumer_version_id,
104
- number: consumer_version_number,
105
- order: consumer_version_order,
106
- pacticipant: consumer,
107
- tags: nil
108
- )
109
- Domain::Pact.new(
110
- id: id,
111
- consumer: consumer,
112
- consumer_version: consumer_version_struct,
113
- provider: provider,
114
- consumer_version_number: consumer_version_number,
115
- revision_number: revision_number,
116
- pact_version_sha: pact_version_sha,
117
- created_at: created_at,
118
- head_tag_names: head_tag_names,
119
- latest_verification: pact_version.latest_verification,
120
- db_model: self
121
- )
122
- end
123
-
124
- def head_tag_names
125
- @head_tag_names ||= PactBroker::Domain::Tag.head_tags_for_pact_publication(self).collect(&:name)
126
- end
127
-
128
- def to_domain_with_content
129
- to_domain.tap do | pact |
130
- pact.json_content = pact_version.content
131
- end
132
- end
133
-
134
- private
135
-
136
- def cached_domain
137
- @cached_domain ||= to_domain
138
- end
139
-
140
- end
141
-
142
- end
143
- end
144
-
145
- # Table: all_pact_publications
146
- # Columns:
147
- # id | integer |
148
- # consumer_id | integer |
149
- # consumer_name | text |
150
- # consumer_version_id | integer |
151
- # consumer_version_number | text |
152
- # consumer_version_order | integer |
153
- # provider_id | integer |
154
- # provider_name | text |
155
- # revision_number | integer |
156
- # pact_version_id | integer |
157
- # pact_version_sha | text |
158
- # created_at | timestamp without time zone |