pact_broker 2.85.1 → 2.86.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release_gem.yml +1 -1
- data/.github/workflows/trigger_pact_docs_update.yml +22 -0
- data/CHANGELOG.md +10 -0
- data/DEVELOPER_DOCUMENTATION.md +0 -2
- data/db/migrations/20210914_add_labels_to_webhooks.rb +14 -0
- data/db/migrations/20210915_add_verified_by_to_verification.rb +6 -0
- data/docker-compose-ci-mysql.yml +1 -0
- data/docs/CONFIGURATION.md +255 -66
- data/docs/configuration.yml +166 -101
- data/lib/db.rb +0 -1
- data/lib/pact_broker/api/contracts/webhook_contract.rb +24 -2
- data/lib/pact_broker/api/decorators/verification_decorator.rb +4 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +27 -4
- data/lib/pact_broker/api/pact_broker_urls.rb +4 -0
- data/lib/pact_broker/api/resources/all_webhooks.rb +2 -2
- data/lib/pact_broker/config/runtime_configuration.rb +4 -0
- data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
- data/lib/pact_broker/db/clean.rb +1 -2
- data/lib/pact_broker/doc/views/pacticipant/label.markdown +12 -0
- data/lib/pact_broker/doc/views/webhooks.markdown +17 -0
- data/lib/pact_broker/domain/pacticipant.rb +4 -0
- data/lib/pact_broker/domain/verification.rb +16 -4
- data/lib/pact_broker/domain/webhook.rb +5 -5
- data/lib/pact_broker/domain/webhook_pacticipant.rb +6 -0
- data/lib/pact_broker/locale/en.yml +1 -0
- data/lib/pact_broker/matrix/head_row.rb +1 -1
- data/lib/pact_broker/matrix/quick_row.rb +0 -1
- data/lib/pact_broker/matrix/repository.rb +0 -1
- data/lib/pact_broker/matrix/row.rb +2 -2
- data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +0 -1
- data/lib/pact_broker/pacts/pact_publication.rb +7 -0
- data/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb +19 -0
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +30 -2
- data/lib/pact_broker/pacts/pact_version.rb +24 -1
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +2 -2
- data/lib/pact_broker/pacts/repository.rb +50 -47
- data/lib/pact_broker/test/http_test_data_builder.rb +37 -10
- data/lib/pact_broker/test/test_data_builder.rb +22 -5
- data/lib/pact_broker/verifications/repository.rb +5 -2
- data/lib/pact_broker/verifications/service.rb +4 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/webhooks/event_listener.rb +4 -2
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +1 -0
- data/lib/pact_broker/webhooks/repository.rb +10 -4
- data/lib/pact_broker/webhooks/webhook.rb +66 -8
- data/script/data/verify-pact-for-multiple-selectors.rb +30 -0
- data/script/docs/generate-configuration-docs.rb +24 -3
- data/script/generate-erd +55 -0
- data/spec/features/create_webhook_spec.rb +55 -10
- data/spec/features/get_pact_spec.rb +2 -3
- data/spec/fixtures/verification.json +4 -0
- data/spec/integration/webhooks/pact_publication_spec.rb +51 -0
- data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +50 -0
- data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +8 -1
- data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +3 -1
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +4 -4
- data/spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb +30 -0
- data/spec/lib/pact_broker/deployments/environment_service_spec.rb +1 -1
- data/spec/lib/pact_broker/matrix/head_row_spec.rb +9 -5
- data/spec/lib/pact_broker/pacts/{latest_tagged_pact_publications_spec.rb → pact_publication_clean_selector_dataset_module_spec.rb} +7 -9
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +32 -0
- data/spec/lib/pact_broker/pacts/repository_spec.rb +33 -0
- data/spec/lib/pact_broker/verifications/service_spec.rb +16 -2
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +158 -15
- data/spec/lib/pact_broker/webhooks/webhook_spec.rb +8 -5
- metadata +16 -11
- data/lib/pact_broker/pacts/all_pact_publications.rb +0 -158
- data/lib/pact_broker/pacts/latest_pact_publications.rb +0 -48
- data/lib/pact_broker/pacts/latest_pact_publications_by_consumer_version.rb +0 -26
- data/lib/pact_broker/pacts/latest_tagged_pact_publications.rb +0 -45
- data/lib/pact_broker/verifications/latest_verification_for_pact_version.rb +0 -39
- 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) {
|
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
|
29
|
-
expect(non_matching_webhooks
|
30
|
-
expect(matching_webhooks.
|
31
|
-
expect(non_matching_webhooks.
|
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
|
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.
|
4
|
+
version: 2.86.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-
|
13
|
+
date: 2021-09-17 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,8 @@ 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
|
614
617
|
- db/migrations/migration_helper.rb
|
615
618
|
- db/test/backwards_compatibility/.rspec
|
616
619
|
- db/test/backwards_compatibility/Appraisals
|
@@ -932,6 +935,7 @@ files:
|
|
932
935
|
- lib/pact_broker/doc/views/pact/tag-prod-version.markdown
|
933
936
|
- lib/pact_broker/doc/views/pact/tag-version.markdown
|
934
937
|
- lib/pact_broker/doc/views/pacticipant/can-i-deploy-badge.markdown
|
938
|
+
- lib/pact_broker/doc/views/pacticipant/label.markdown
|
935
939
|
- lib/pact_broker/doc/views/pacticipant/versions.markdown
|
936
940
|
- lib/pact_broker/doc/views/pending-provider-pacts.markdown
|
937
941
|
- lib/pact_broker/doc/views/provider-pacts-for-verification.markdown
|
@@ -949,6 +953,7 @@ files:
|
|
949
953
|
- lib/pact_broker/domain/verification.rb
|
950
954
|
- lib/pact_broker/domain/version.rb
|
951
955
|
- lib/pact_broker/domain/webhook.rb
|
956
|
+
- lib/pact_broker/domain/webhook_pacticipant.rb
|
952
957
|
- lib/pact_broker/domain/webhook_request.rb
|
953
958
|
- lib/pact_broker/error.rb
|
954
959
|
- lib/pact_broker/errors.rb
|
@@ -995,7 +1000,6 @@ files:
|
|
995
1000
|
- lib/pact_broker/pacticipants/generate_display_name.rb
|
996
1001
|
- lib/pact_broker/pacticipants/repository.rb
|
997
1002
|
- lib/pact_broker/pacticipants/service.rb
|
998
|
-
- lib/pact_broker/pacts/all_pact_publications.rb
|
999
1003
|
- lib/pact_broker/pacts/build_verifiable_pact_notices.rb
|
1000
1004
|
- lib/pact_broker/pacts/content.rb
|
1001
1005
|
- lib/pact_broker/pacts/create_formatted_diff.rb
|
@@ -1005,15 +1009,13 @@ files:
|
|
1005
1009
|
- lib/pact_broker/pacts/generate_sha.rb
|
1006
1010
|
- lib/pact_broker/pacts/head_pact.rb
|
1007
1011
|
- 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
1012
|
- lib/pact_broker/pacts/lazy_loaders.rb
|
1012
1013
|
- lib/pact_broker/pacts/merger.rb
|
1013
1014
|
- lib/pact_broker/pacts/metadata.rb
|
1014
1015
|
- lib/pact_broker/pacts/order_hash_keys.rb
|
1015
1016
|
- lib/pact_broker/pacts/pact_params.rb
|
1016
1017
|
- lib/pact_broker/pacts/pact_publication.rb
|
1018
|
+
- lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module.rb
|
1017
1019
|
- lib/pact_broker/pacts/pact_publication_dataset_module.rb
|
1018
1020
|
- lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb
|
1019
1021
|
- lib/pact_broker/pacts/pact_publication_wip_dataset_module.rb
|
@@ -1087,7 +1089,6 @@ files:
|
|
1087
1089
|
- lib/pact_broker/ui/views/matrix/show.haml
|
1088
1090
|
- lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb
|
1089
1091
|
- lib/pact_broker/verifications/latest_verification_for_consumer_version_tag.rb
|
1090
|
-
- lib/pact_broker/verifications/latest_verification_for_pact_version.rb
|
1091
1092
|
- lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb
|
1092
1093
|
- lib/pact_broker/verifications/placeholder_verification.rb
|
1093
1094
|
- lib/pact_broker/verifications/pseudo_branch_status.rb
|
@@ -1248,6 +1249,7 @@ files:
|
|
1248
1249
|
- script/data/issue-494.rb
|
1249
1250
|
- script/data/pending.rb
|
1250
1251
|
- script/data/tags.rb
|
1252
|
+
- script/data/verify-pact-for-multiple-selectors.rb
|
1251
1253
|
- script/data/webhook.rb
|
1252
1254
|
- script/db-spec.sh
|
1253
1255
|
- script/demonstrate-version-branches.rb
|
@@ -1266,6 +1268,7 @@ files:
|
|
1266
1268
|
- script/foo-bar-verification.json
|
1267
1269
|
- script/foo-bar.json
|
1268
1270
|
- script/generate-certificates-for-webooks-certificate-spec.rb
|
1271
|
+
- script/generate-erd
|
1269
1272
|
- script/import-pg-database.sh
|
1270
1273
|
- script/insert-self-signed-certificate-from-url.rb
|
1271
1274
|
- script/issues/consumer-version-selectors-docs/issue-text.txt
|
@@ -1421,6 +1424,7 @@ files:
|
|
1421
1424
|
- spec/integration/ui/index_spec.rb
|
1422
1425
|
- spec/integration/ui/matrix_spec.rb
|
1423
1426
|
- spec/integration/webhooks/certificate_spec.rb
|
1427
|
+
- spec/integration/webhooks/pact_publication_spec.rb
|
1424
1428
|
- spec/lib/pact/doc/generator_spec.rb
|
1425
1429
|
- spec/lib/pact/doc/interaction_view_model_spec.rb
|
1426
1430
|
- spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
|
@@ -1512,6 +1516,7 @@ files:
|
|
1512
1516
|
- spec/lib/pact_broker/build_http_options_spec.rb
|
1513
1517
|
- spec/lib/pact_broker/certificates/service_spec.rb
|
1514
1518
|
- spec/lib/pact_broker/config/load_spec.rb
|
1519
|
+
- spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb
|
1515
1520
|
- spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
|
1516
1521
|
- spec/lib/pact_broker/config/runtime_configuration_spec.rb
|
1517
1522
|
- spec/lib/pact_broker/config/save_spec.rb
|
@@ -1588,10 +1593,10 @@ files:
|
|
1588
1593
|
- spec/lib/pact_broker/pacts/diff_spec.rb
|
1589
1594
|
- spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
|
1590
1595
|
- spec/lib/pact_broker/pacts/generate_sha_spec.rb
|
1591
|
-
- spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb
|
1592
1596
|
- spec/lib/pact_broker/pacts/merger_spec.rb
|
1593
1597
|
- spec/lib/pact_broker/pacts/metadata_spec.rb
|
1594
1598
|
- spec/lib/pact_broker/pacts/pact_params_spec.rb
|
1599
|
+
- spec/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module_spec.rb
|
1595
1600
|
- spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb
|
1596
1601
|
- spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb
|
1597
1602
|
- spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb
|
@@ -1622,7 +1627,6 @@ files:
|
|
1622
1627
|
- spec/lib/pact_broker/ui/view_models/index_items_spec.rb
|
1623
1628
|
- spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb
|
1624
1629
|
- 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
1630
|
- spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb
|
1627
1631
|
- spec/lib/pact_broker/verifications/repository_spec.rb
|
1628
1632
|
- spec/lib/pact_broker/verifications/sequence_spec.rb
|
@@ -1899,6 +1903,7 @@ test_files:
|
|
1899
1903
|
- spec/integration/ui/index_spec.rb
|
1900
1904
|
- spec/integration/ui/matrix_spec.rb
|
1901
1905
|
- spec/integration/webhooks/certificate_spec.rb
|
1906
|
+
- spec/integration/webhooks/pact_publication_spec.rb
|
1902
1907
|
- spec/lib/pact/doc/generator_spec.rb
|
1903
1908
|
- spec/lib/pact/doc/interaction_view_model_spec.rb
|
1904
1909
|
- spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
|
@@ -1990,6 +1995,7 @@ test_files:
|
|
1990
1995
|
- spec/lib/pact_broker/build_http_options_spec.rb
|
1991
1996
|
- spec/lib/pact_broker/certificates/service_spec.rb
|
1992
1997
|
- spec/lib/pact_broker/config/load_spec.rb
|
1998
|
+
- spec/lib/pact_broker/config/runtime_configuration_documentation_spec.rb
|
1993
1999
|
- spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb
|
1994
2000
|
- spec/lib/pact_broker/config/runtime_configuration_spec.rb
|
1995
2001
|
- spec/lib/pact_broker/config/save_spec.rb
|
@@ -2066,10 +2072,10 @@ test_files:
|
|
2066
2072
|
- spec/lib/pact_broker/pacts/diff_spec.rb
|
2067
2073
|
- spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
|
2068
2074
|
- spec/lib/pact_broker/pacts/generate_sha_spec.rb
|
2069
|
-
- spec/lib/pact_broker/pacts/latest_tagged_pact_publications_spec.rb
|
2070
2075
|
- spec/lib/pact_broker/pacts/merger_spec.rb
|
2071
2076
|
- spec/lib/pact_broker/pacts/metadata_spec.rb
|
2072
2077
|
- spec/lib/pact_broker/pacts/pact_params_spec.rb
|
2078
|
+
- spec/lib/pact_broker/pacts/pact_publication_clean_selector_dataset_module_spec.rb
|
2073
2079
|
- spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb
|
2074
2080
|
- spec/lib/pact_broker/pacts/pact_publication_latest_verification_spec.rb
|
2075
2081
|
- spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb
|
@@ -2100,7 +2106,6 @@ test_files:
|
|
2100
2106
|
- spec/lib/pact_broker/ui/view_models/index_items_spec.rb
|
2101
2107
|
- spec/lib/pact_broker/ui/view_models/matrix_deployed_version_spec.rb
|
2102
2108
|
- 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
2109
|
- spec/lib/pact_broker/verifications/pseudo_branch_status_spec.rb
|
2105
2110
|
- spec/lib/pact_broker/verifications/repository_spec.rb
|
2106
2111
|
- spec/lib/pact_broker/verifications/sequence_spec.rb
|
@@ -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 |
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "pact_broker/pacts/latest_pact_publications_by_consumer_version"
|
2
|
-
require "pact_broker/pacts/head_pact"
|
3
|
-
|
4
|
-
module PactBroker
|
5
|
-
module Pacts
|
6
|
-
|
7
|
-
# latest pact for each consumer/provider pair
|
8
|
-
class LatestPactPublications < LatestPactPublicationsByConsumerVersion
|
9
|
-
set_dataset(:latest_pact_publications)
|
10
|
-
|
11
|
-
# def dataset_module
|
12
|
-
# def where_age_less_than(days)
|
13
|
-
# start_date = Date.today - days
|
14
|
-
# where{ latest_pact_publications[:created_at] >= start_date }
|
15
|
-
# end
|
16
|
-
|
17
|
-
# def for_selector(selector)
|
18
|
-
# query = self
|
19
|
-
# query = query.where(consumer_name: selector.pacticipant_name) if selector.pacticipant_name
|
20
|
-
# query = query.where(tag_name: selector.tag) if selector.tag && selector.tag.is_a?(String)
|
21
|
-
# query = query.where_age_less_than(selector.max_age) if selector.max_age
|
22
|
-
# query
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
|
26
|
-
# This pact may well be the latest for certain tags, but in this query
|
27
|
-
# we don't know what they are
|
28
|
-
def to_domain
|
29
|
-
HeadPact.new(super, consumer_version_number, nil)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Table: latest_pact_publications
|
36
|
-
# Columns:
|
37
|
-
# id | integer |
|
38
|
-
# consumer_id | integer |
|
39
|
-
# consumer_name | text |
|
40
|
-
# consumer_version_id | integer |
|
41
|
-
# consumer_version_number | text |
|
42
|
-
# consumer_version_order | integer |
|
43
|
-
# provider_id | integer |
|
44
|
-
# provider_name | text |
|
45
|
-
# revision_number | integer |
|
46
|
-
# pact_version_id | integer |
|
47
|
-
# pact_version_sha | text |
|
48
|
-
# created_at | timestamp without time zone |
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "pact_broker/pacts/all_pact_publications"
|
2
|
-
|
3
|
-
module PactBroker
|
4
|
-
module Pacts
|
5
|
-
|
6
|
-
class LatestPactPublicationsByConsumerVersion < AllPactPublications
|
7
|
-
set_dataset(:latest_pact_publications_by_consumer_versions)
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# Table: latest_pact_publications_by_consumer_versions
|
14
|
-
# Columns:
|
15
|
-
# id | integer |
|
16
|
-
# consumer_id | integer |
|
17
|
-
# consumer_name | text |
|
18
|
-
# consumer_version_id | integer |
|
19
|
-
# consumer_version_number | text |
|
20
|
-
# consumer_version_order | integer |
|
21
|
-
# provider_id | integer |
|
22
|
-
# provider_name | text |
|
23
|
-
# revision_number | integer |
|
24
|
-
# pact_version_id | integer |
|
25
|
-
# pact_version_sha | text |
|
26
|
-
# created_at | timestamp without time zone |
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "pact_broker/pacts/latest_pact_publications_by_consumer_version"
|
2
|
-
require "pact_broker/pacts/head_pact"
|
3
|
-
|
4
|
-
module PactBroker
|
5
|
-
module Pacts
|
6
|
-
class LatestTaggedPactPublications < LatestPactPublicationsByConsumerVersion
|
7
|
-
set_dataset(:latest_tagged_pact_publications)
|
8
|
-
|
9
|
-
dataset_module do
|
10
|
-
def where_age_less_than(days)
|
11
|
-
start_date = Date.today - days
|
12
|
-
where{ latest_tagged_pact_publications[:created_at] >= start_date }
|
13
|
-
end
|
14
|
-
|
15
|
-
def for_selector(selector)
|
16
|
-
query = self
|
17
|
-
query = query.where(consumer_name: selector.pacticipant_name) if selector.pacticipant_name
|
18
|
-
query = query.where(tag_name: selector.tag) if selector.tag && selector.tag.is_a?(String)
|
19
|
-
query = query.where_age_less_than(selector.max_age) if selector.max_age
|
20
|
-
query
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_domain
|
25
|
-
HeadPact.new(super, consumer_version_number, tag_name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Table: latest_tagged_pact_publications
|
32
|
-
# Columns:
|
33
|
-
# id | integer |
|
34
|
-
# consumer_id | integer |
|
35
|
-
# consumer_name | text |
|
36
|
-
# consumer_version_id | integer |
|
37
|
-
# consumer_version_number | text |
|
38
|
-
# consumer_version_order | integer |
|
39
|
-
# provider_id | integer |
|
40
|
-
# provider_name | text |
|
41
|
-
# revision_number | integer |
|
42
|
-
# pact_version_id | integer |
|
43
|
-
# pact_version_sha | text |
|
44
|
-
# created_at | timestamp without time zone |
|
45
|
-
# tag_name | text |
|