pact_broker 2.40.0 → 2.41.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/DEVELOPER_DOCUMENTATION.md +11 -0
  4. data/db/ddl_statements/head_pact_tags.rb +10 -0
  5. data/db/ddl_statements/latest_pact_consumer_version_orders.rb +16 -0
  6. data/db/ddl_statements/latest_pact_publications_by_consumer_versions.rb +16 -0
  7. data/db/ddl_statements/latest_tagged_pact_consumer_version_orders.rb +23 -0
  8. data/db/ddl_statements/latest_verification_ids_for_consumer_version_tags.rb +15 -0
  9. data/db/ddl_statements/{latest_verification_ids_for_pact_versions_v001.rb → latest_verification_ids_for_pact_versions.rb} +0 -0
  10. data/db/migrations/000028_create_all_pact_publications.rb +1 -0
  11. data/db/migrations/20180311_optimise_head_matrix.rb +1 -9
  12. data/db/migrations/20180722_recreate_views.rb +6 -19
  13. data/db/migrations/20191028_optimise_latest_tagged_pact_cv_orders.rb +13 -0
  14. data/db/migrations/20191030_optimise_latest_pact_publications_by_consumer_versions_.rb +13 -0
  15. data/db/migrations/20191031_optimise_latest_verification_ids_for_consumer_version_tags.rb +13 -0
  16. data/db/migrations/20191101_create_head_pact_tags.rb +11 -0
  17. data/lib/db.rb +1 -0
  18. data/lib/pact_broker/api/contracts/dry_validation_predicates.rb +15 -0
  19. data/lib/pact_broker/api/contracts/dry_validation_workarounds.rb +38 -0
  20. data/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb +34 -0
  21. data/lib/pact_broker/api/contracts/verifiable_pacts_query_schema.rb +12 -20
  22. data/lib/pact_broker/api/decorators/matrix_decorator.rb +25 -6
  23. data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +4 -12
  24. data/lib/pact_broker/api/decorators/verifiable_pact_decorator.rb +5 -2
  25. data/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator.rb +21 -9
  26. data/lib/pact_broker/api/renderers/integrations_dot_renderer.rb +1 -1
  27. data/lib/pact_broker/api/resources/base_resource.rb +1 -1
  28. data/lib/pact_broker/api/resources/can_i_deploy.rb +2 -9
  29. data/lib/pact_broker/api/resources/matrix.rb +2 -8
  30. data/lib/pact_broker/api/resources/matrix_for_consumer_and_provider.rb +1 -0
  31. data/lib/pact_broker/api/resources/provider_pacts_for_verification.rb +36 -7
  32. data/lib/pact_broker/app.rb +1 -0
  33. data/lib/pact_broker/db/data_migrations/migrate_webhook_headers.rb +1 -1
  34. data/lib/pact_broker/db/seed_example_data.rb +8 -5
  35. data/lib/pact_broker/diagnostic/resources/base_resource.rb +0 -8
  36. data/lib/pact_broker/domain/index_item.rb +47 -16
  37. data/lib/pact_broker/domain/pact.rb +12 -4
  38. data/lib/pact_broker/domain/version.rb +2 -0
  39. data/lib/pact_broker/hash_refinements.rb +48 -0
  40. data/lib/pact_broker/index/page.rb +12 -0
  41. data/lib/pact_broker/index/service.rb +156 -21
  42. data/lib/pact_broker/integrations/integration.rb +22 -0
  43. data/lib/pact_broker/locale/en.yml +2 -0
  44. data/lib/pact_broker/logging.rb +0 -1
  45. data/lib/pact_broker/matrix/aggregated_row.rb +3 -9
  46. data/lib/pact_broker/matrix/deployment_status_summary.rb +5 -5
  47. data/lib/pact_broker/matrix/head_row.rb +2 -0
  48. data/lib/pact_broker/matrix/quick_row.rb +7 -7
  49. data/lib/pact_broker/matrix/repository.rb +2 -4
  50. data/lib/pact_broker/pacticipants/repository.rb +1 -1
  51. data/lib/pact_broker/pacts/pact_publication.rb +27 -4
  52. data/lib/pact_broker/pacts/repository.rb +41 -18
  53. data/lib/pact_broker/pacts/service.rb +23 -3
  54. data/lib/pact_broker/pacts/verifiable_pact.rb +8 -2
  55. data/lib/pact_broker/pacts/verifiable_pact_messages.rb +14 -8
  56. data/lib/pact_broker/string_refinements.rb +36 -1
  57. data/lib/pact_broker/tags/head_pact_tags.rb +12 -0
  58. data/lib/pact_broker/tags/tag_with_latest_flag.rb +0 -1
  59. data/lib/pact_broker/test/test_data_builder.rb +1 -1
  60. data/lib/pact_broker/ui/controllers/index.rb +23 -2
  61. data/lib/pact_broker/ui/view_models/index_item.rb +7 -1
  62. data/lib/pact_broker/ui/view_models/index_items.rb +10 -8
  63. data/lib/pact_broker/ui/view_models/matrix_line.rb +14 -21
  64. data/lib/pact_broker/ui/view_models/matrix_tag.rb +6 -8
  65. data/lib/pact_broker/ui/views/index/_pagination.haml +31 -0
  66. data/lib/pact_broker/ui/views/index/show-with-tags.haml +6 -3
  67. data/lib/pact_broker/ui/views/index/show.haml +5 -2
  68. data/lib/pact_broker/ui/views/matrix/show.haml +6 -9
  69. data/lib/pact_broker/version.rb +1 -1
  70. data/lib/pact_broker/webhooks/webhook.rb +2 -2
  71. data/lib/pact_broker/webhooks/webhook_execution_result.rb +3 -18
  72. data/public/javascripts/matrix.js +26 -1
  73. data/public/javascripts/pagination.js +1127 -0
  74. data/public/stylesheets/index.css +13 -0
  75. data/public/stylesheets/matrix.css +10 -1
  76. data/spec/features/get_provider_pacts_for_verification_spec.rb +44 -9
  77. data/spec/features/pending_pacts_spec.rb +1 -1
  78. data/spec/features/wip_pacts_spec.rb +138 -0
  79. data/spec/integration/app_spec.rb +1 -1
  80. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema_spec.rb +90 -0
  81. data/spec/lib/pact_broker/api/contracts/verifiable_pacts_query_schema_spec.rb +26 -4
  82. data/spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb +36 -2
  83. data/spec/lib/pact_broker/api/decorators/verifiable_pact_decorator_spec.rb +24 -1
  84. data/spec/lib/pact_broker/api/decorators/verifiable_pacts_query_decorator_spec.rb +62 -18
  85. data/spec/lib/pact_broker/api/resources/base_resource_spec.rb +10 -0
  86. data/spec/lib/pact_broker/api/resources/provider_pacts_for_verification_spec.rb +75 -6
  87. data/spec/lib/pact_broker/hash_refinements_spec.rb +24 -0
  88. data/spec/lib/pact_broker/index/service_spec.rb +38 -2
  89. data/spec/lib/pact_broker/integrations/integration_spec.rb +79 -41
  90. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +2 -0
  91. data/spec/lib/pact_broker/pacts/repository_find_wip_pact_versions_for_provider_spec.rb +17 -2
  92. data/spec/lib/pact_broker/pacts/service_spec.rb +56 -0
  93. data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +12 -1
  94. data/spec/lib/pact_broker/ui/controllers/index_spec.rb +28 -6
  95. data/spec/lib/pact_broker/ui/view_models/index_items_spec.rb +8 -29
  96. data/spec/lib/pact_broker/ui/view_models/matrix_line_spec.rb +41 -0
  97. metadata +24 -3
@@ -29,6 +29,7 @@ module PactBroker
29
29
  let(:pact) do
30
30
  double('pact',
31
31
  pending: true,
32
+ wip: wip,
32
33
  name: "name",
33
34
  provider_name: "Bar",
34
35
  pending_provider_tags: pending_provider_tags,
@@ -37,7 +38,9 @@ module PactBroker
37
38
  let(:pending_provider_tags) { %w[dev] }
38
39
  let(:consumer_tags) { %w[dev] }
39
40
  let(:json) { decorator.to_json(options) }
40
- let(:options) { { user_options: { base_url: 'http://example.org' } } }
41
+ let(:options) { { user_options: { base_url: 'http://example.org', include_pending_status: include_pending_status } } }
42
+ let(:include_pending_status) { true }
43
+ let(:wip){ false }
41
44
 
42
45
  subject { JSON.parse(json) }
43
46
 
@@ -49,6 +52,26 @@ module PactBroker
49
52
  expect(decorator).to receive(:pact_version_url).with(pact, 'http://example.org')
50
53
  subject
51
54
  end
55
+
56
+ context "when include_pending_status is false" do
57
+ let(:include_pending_status) { false }
58
+
59
+ it "does not include the pending flag" do
60
+ expect(subject['verificationProperties']).to_not have_key('pending')
61
+ end
62
+
63
+ it "does not include the pending reason" do
64
+ expect(subject['verificationProperties']).to_not have_key('pendingReason')
65
+ end
66
+ end
67
+
68
+ context "when wip is true" do
69
+ let(:wip) { true }
70
+
71
+ it "includes the wip flag" do
72
+ expect(subject['verificationProperties']['wip']).to be true
73
+ end
74
+ end
52
75
  end
53
76
  end
54
77
  end
@@ -4,40 +4,84 @@ module PactBroker
4
4
  module Api
5
5
  module Decorators
6
6
  describe VerifiablePactsQueryDecorator do
7
- let(:params) do
8
- {
9
- "provider_version_tags" => provider_version_tags,
10
- "consumer_version_selectors" => consumer_version_selectors
11
- }
12
- end
7
+
13
8
  let(:provider_version_tags) { %w[dev] }
14
- let(:consumer_version_selectors) do
15
- [{"tag" => "dev", "ignored" => "foo"}]
16
- end
17
9
 
18
10
  subject { VerifiablePactsQueryDecorator.new(OpenStruct.new).from_hash(params) }
19
11
 
20
- context "when latest is not specified" do
21
- it "defaults to nil" do
22
- expect(subject.consumer_version_selectors.first.latest).to be nil
12
+ context "when parsing JSON params" do
13
+ let(:params) do
14
+ {
15
+ "providerVersionTags" => provider_version_tags,
16
+ "consumerVersionSelectors" => consumer_version_selectors
17
+ }
18
+ end
19
+
20
+ let(:consumer_version_selectors) do
21
+ [{"tag" => "dev", "ignored" => "foo", "latest" => true}]
22
+ end
23
+
24
+ context "when latest is not specified" do
25
+ let(:consumer_version_selectors) do
26
+ [{"tag" => "dev"}]
27
+ end
28
+
29
+ it "defaults to nil" do
30
+ expect(subject.consumer_version_selectors.first.latest).to be nil
31
+ end
32
+ end
33
+
34
+ it "parses the latest as a boolean" do
35
+ expect(subject.consumer_version_selectors.first.latest).to be true
36
+ end
37
+
38
+ context "when there are no consumer_version_selectors" do
39
+ let(:params) { {} }
40
+
41
+ it "returns an empty array" do
42
+ expect(subject.consumer_version_selectors).to eq []
43
+ end
44
+ end
45
+
46
+ context "when there are no provider_version_tags" do
47
+ let(:params) { {} }
48
+
49
+ it "returns an empty array" do
50
+ expect(subject.provider_version_tags).to eq []
51
+ end
23
52
  end
24
53
  end
25
54
 
26
- context "when latest is a string" do
55
+ context "when parsing query string params" do
56
+ let(:params) do
57
+ {
58
+ "provider_version_tags" => provider_version_tags,
59
+ "consumer_version_selectors" => consumer_version_selectors
60
+ }
61
+ end
62
+
27
63
  let(:consumer_version_selectors) do
28
64
  [{"tag" => "dev", "latest" => "true"}]
29
65
  end
30
66
 
31
- it "casts it to a boolean" do
67
+ it "parses the provider_version_tags" do
68
+ expect(subject.provider_version_tags).to eq provider_version_tags
69
+ end
70
+
71
+ it "parses a string 'latest' to a boolean" do
32
72
  expect(subject.consumer_version_selectors.first.latest).to be true
33
73
  end
34
74
  end
35
75
 
36
- context "when there are no consumer_version_selectors" do
37
- let(:params) { {} }
76
+ context "when specifying include_wip_pacts_since" do
77
+ let(:params) do
78
+ {
79
+ "include_wip_pacts_since" => "2013-02-13T20:04:45.000+11:00"
80
+ }
81
+ end
38
82
 
39
- it "returns an empty array" do
40
- expect(subject.consumer_version_selectors).to eq []
83
+ it "parses the date" do
84
+ expect(subject.include_wip_pacts_since).to eq DateTime.parse("2013-02-13T20:04:45.000+11:00")
41
85
  end
42
86
  end
43
87
  end
@@ -31,6 +31,16 @@ module PactBroker
31
31
  it "includes OPTIONS in the list of allowed_methods" do
32
32
  expect(resource.new(request, response).allowed_methods).to include "OPTIONS"
33
33
  end
34
+
35
+ it "calls super in its constructor" do
36
+ expect(PactBroker.configuration.before_resource).to receive(:call)
37
+ resource.new(request, response)
38
+ end
39
+
40
+ it "calls super in finish_request" do
41
+ expect(PactBroker.configuration.after_resource).to receive(:call)
42
+ resource.new(request, response).finish_request
43
+ end
34
44
  end
35
45
  end
36
46
  end
@@ -14,18 +14,87 @@ module PactBroker
14
14
  let(:pacts) { double('pacts') }
15
15
  let(:path) { '/pacts/provider/Bar/for-verification' }
16
16
  let(:decorator) { instance_double('PactBroker::Api::Decorators::VerifiablePactsDecorator') }
17
+ let(:query) do
18
+ {
19
+ provider_version_tags: ['master'],
20
+ consumer_version_selectors: [ { tag: 'dev', latest: 'true' }],
21
+ include_pending_status: false,
22
+ include_wip_pacts_since: '2018-01-01'
23
+ }
24
+ end
17
25
 
18
- subject { get(path, provider_version_tags: ['master'], consumer_version_selectors: [ { tag: "dev", latest: true}]) }
26
+ subject { get(path, query) }
19
27
 
20
- it "finds the pacts for verification by the provider" do
21
- # Naughty not mocking out the query parsing...
22
- expect(PactBroker::Pacts::Service).to receive(:find_for_verification).with("Bar", ["master"], [ OpenStruct.new(tag: "dev", latest: true)])
23
- subject
28
+ describe "GET" do
29
+ it "finds the pacts for verification by the provider" do
30
+ # Naughty not mocking out the query parsing...
31
+ expect(PactBroker::Pacts::Service).to receive(:find_for_verification).with(
32
+ "Bar",
33
+ ["master"],
34
+ [OpenStruct.new(tag: "dev", latest: true)],
35
+ { include_wip_pacts_since: DateTime.parse('2018-01-01') })
36
+ subject
37
+ end
38
+
39
+ context "when there are validation errors" do
40
+ let(:query) do
41
+ {
42
+ provider_version_tags: true,
43
+ }
44
+ end
45
+
46
+ it "returns the keys with the right case" do
47
+ expect(JSON.parse(subject.body)['errors']).to have_key('provider_version_tags')
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "POST" do
53
+ let(:request_body) do
54
+ {
55
+ providerVersionTags: ['master'],
56
+ consumerVersionSelectors: [ { tag: 'dev', latest: true }],
57
+ includePendingStatus: false,
58
+ includeWipPactsSince: '2018-01-01'
59
+ }
60
+ end
61
+
62
+ let(:request_headers) do
63
+ {
64
+ 'CONTENT_TYPE' => 'application/json',
65
+ 'HTTP_ACCEPT' => 'application/hal+json'
66
+ }
67
+ end
68
+
69
+ subject { post(path, request_body.to_json, request_headers) }
70
+
71
+ it "finds the pacts for verification by the provider" do
72
+ # Naughty not mocking out the query parsing...
73
+ expect(PactBroker::Pacts::Service).to receive(:find_for_verification).with(
74
+ "Bar",
75
+ ["master"],
76
+ [OpenStruct.new(tag: "dev", latest: true)],
77
+ { include_wip_pacts_since: DateTime.parse('2018-01-01') })
78
+ subject
79
+ end
80
+
81
+ context "when there are validation errors" do
82
+ let(:request_body) do
83
+ {
84
+ providerVersionTags: true
85
+ }
86
+ end
87
+
88
+ it "returns the keys with the right case" do
89
+ expect(JSON.parse(subject.body)['errors']).to have_key('providerVersionTags')
90
+ end
91
+ end
24
92
  end
25
93
 
26
- it "sets the correct resource title" do
94
+ it "uses the correct options for the decorator" do
27
95
  expect(decorator).to receive(:to_json) do | options |
28
96
  expect(options[:user_options][:title]).to eq "Pacts to be verified by provider Bar"
97
+ expect(options[:user_options][:include_pending_status]).to eq false
29
98
  end
30
99
  subject
31
100
  end
@@ -11,5 +11,29 @@ module PactBroker
11
11
  it "merges" do
12
12
  expect(a.deep_merge(b)).to eq expected
13
13
  end
14
+
15
+ describe "snakecase_keys" do
16
+ let(:hash_1) do
17
+ {
18
+ "fooBar" => {
19
+ :meepMoop => "blahBlah",
20
+ "already_snake" => ""
21
+ }
22
+ }
23
+ end
24
+
25
+ let(:expected) do
26
+ {
27
+ "foo_bar" => {
28
+ :meep_moop => "blahBlah",
29
+ "already_snake" => ""
30
+ }
31
+ }
32
+ end
33
+
34
+ it "snake cases the keys" do
35
+ expect(hash_1.snakecase_keys).to eq expected
36
+ end
37
+ end
14
38
  end
15
39
  end
@@ -4,13 +4,19 @@ require 'pact_broker/domain/tag'
4
4
  require 'pact_broker/domain/pact'
5
5
 
6
6
  module PactBroker
7
-
8
7
  module Index
9
8
  describe Service do
10
9
  let(:td) { TestDataBuilder.new }
11
10
  let(:tags) { ['prod', 'production'] }
12
- let(:options) { { tags: tags } }
11
+ let(:options) { { tags: tags, optimised: optimised, page_size: page_size, page_number: page_number } }
12
+ let(:page_number) { nil }
13
+ let(:page_size) { nil }
13
14
  let(:rows) { subject.find_index_items(options) }
15
+ let(:optimised) { true }
16
+
17
+ before do
18
+ td.create_global_webhook
19
+ end
14
20
 
15
21
  subject{ Service }
16
22
 
@@ -252,6 +258,36 @@ module PactBroker
252
258
  end
253
259
  end
254
260
  end
261
+
262
+ describe "with pagination" do
263
+ let(:page_number) { 1 }
264
+ let(:page_size) { 2 }
265
+ let(:tags) { nil }
266
+
267
+ before do
268
+ td.create_pact_with_hierarchy("Foo1", "1", "Bar1")
269
+ .create_pact_with_hierarchy("Foo2", "1", "Bar2")
270
+ .create_pact_with_hierarchy("Foo3", "1", "Bar3")
271
+ end
272
+
273
+ it "it returns the total number of records" do
274
+ expect(rows.pagination_record_count).to eq 3
275
+ end
276
+
277
+ describe "the first page" do
278
+ it "contains 2 rows" do
279
+ expect(rows.count).to eq 2
280
+ end
281
+ end
282
+
283
+ describe "the second page" do
284
+ let(:page_number) { 2 }
285
+
286
+ it "contains 1 row" do
287
+ expect(rows.count).to eq 1
288
+ end
289
+ end
290
+ end
255
291
  end
256
292
 
257
293
  describe "find_index_items_for_api" do
@@ -3,58 +3,96 @@ require 'pact_broker/integrations/integration'
3
3
  module PactBroker
4
4
  module Integrations
5
5
  describe Integration do
6
- before do
7
- td.set_now(DateTime.new(2019, 1, 1))
8
- .create_pact_with_hierarchy("Foo", "1", "Bar")
9
- .set_now(DateTime.new(2019, 1, 2))
10
- .create_consumer_version("2")
11
- .create_pact
12
- .set_now(DateTime.new(2019, 1, 3))
13
- .create_verification(provider_version: "3")
14
- .set_now(DateTime.new(2019, 1, 4))
15
- .create_verification(provider_version: "4", number: 2)
16
- end
17
-
18
- it "has a relationship to the latest pact" do
19
- integration = Integration.eager(:latest_pact).all.first
20
- expect(integration.latest_pact.consumer_version_number).to eq "2"
21
- end
6
+ describe "relationships" do
7
+ before do
8
+ td.set_now(DateTime.new(2019, 1, 1))
9
+ .create_pact_with_hierarchy("Foo", "1", "Bar")
10
+ .set_now(DateTime.new(2019, 1, 2))
11
+ .create_consumer_version("2")
12
+ .create_pact
13
+ .set_now(DateTime.new(2019, 1, 3))
14
+ .create_verification(provider_version: "3")
15
+ .set_now(DateTime.new(2019, 1, 4))
16
+ .create_verification(provider_version: "4", number: 2)
17
+ end
22
18
 
23
- it "has a relationship to the latest verification via the latest pact" do
24
- integration = Integration.eager(latest_pact: :latest_verification).all.first
25
- expect(integration.latest_pact.latest_verification.provider_version_number).to eq "4"
26
- end
19
+ it "has a relationship to the latest pact" do
20
+ integration = Integration.eager(:latest_pact).all.first
21
+ expect(integration.latest_pact.consumer_version_number).to eq "2"
22
+ end
27
23
 
28
- it "has a verification status" do
29
- expect(Integration.first.verification_status_for_latest_pact).to be_instance_of(PactBroker::Verifications::PseudoBranchStatus)
30
- end
24
+ it "has a relationship to the latest verification via the latest pact" do
25
+ integration = Integration.eager(latest_pact: :latest_verification).all.first
26
+ expect(integration.latest_pact.latest_verification.provider_version_number).to eq "4"
27
+ end
31
28
 
32
- it "has a latest verification - this may not be the same as the latest verification for the latest pact" do
33
- integration = Integration.eager(:latest_verification).all.first
34
- expect(integration.latest_verification.provider_version_number).to eq "4"
35
- end
29
+ it "has a verification status" do
30
+ expect(Integration.first.verification_status_for_latest_pact).to be_instance_of(PactBroker::Verifications::PseudoBranchStatus)
31
+ end
36
32
 
37
- describe "latest_pact_or_verification_publication_date" do
38
- context "when the last publication is a verification" do
39
- it "returns the verification execution date" do
40
- date = td.in_utc { DateTime.new(2019, 1, 4) }
41
- expect(Integration.first.latest_pact_or_verification_publication_date.to_datetime).to eq date
42
- end
33
+ it "has a latest verification - this may not be the same as the latest verification for the latest pact" do
34
+ integration = Integration.eager(:latest_verification).all.first
35
+ expect(integration.latest_verification.provider_version_number).to eq "4"
43
36
  end
44
37
 
45
- context "when the last publication is a pact" do
46
- before do
47
- td.set_now(DateTime.new(2019, 1, 5))
48
- .create_consumer_version("3")
49
- .create_pact
38
+ describe "latest_pact_or_verification_publication_date" do
39
+ context "when the last publication is a verification" do
40
+ it "returns the verification execution date" do
41
+ date = td.in_utc { DateTime.new(2019, 1, 4) }
42
+ expect(Integration.first.latest_pact_or_verification_publication_date.to_datetime).to eq date
43
+ end
50
44
  end
51
45
 
52
- it "returns the pact publication date" do
53
- date = td.in_utc { DateTime.new(2019, 1, 5) }
54
- expect(Integration.first.latest_pact_or_verification_publication_date.to_datetime).to eq date
46
+ context "when the last publication is a pact" do
47
+ before do
48
+ td.set_now(DateTime.new(2019, 1, 5))
49
+ .create_consumer_version("3")
50
+ .create_pact
51
+ end
52
+
53
+ it "returns the pact publication date" do
54
+ date = td.in_utc { DateTime.new(2019, 1, 5) }
55
+ expect(Integration.first.latest_pact_or_verification_publication_date.to_datetime).to eq date
56
+ end
55
57
  end
56
58
  end
57
59
  end
60
+
61
+ describe "latest_triggered_webhooks" do
62
+ before do
63
+ td.create_consumer("Foo")
64
+ .create_provider("Bar")
65
+ .create_consumer_version
66
+ .create_pact
67
+ .create_global_webhook
68
+ .create_triggered_webhook
69
+ .create_webhook_execution
70
+ end
71
+
72
+ it "returns a list of triggered webhooks" do
73
+ integrations = Integration.eager(:latest_triggered_webhooks).all
74
+ expect(integrations.first.latest_triggered_webhooks.count).to eq 1
75
+ end
76
+ end
77
+
78
+ describe "webhooks" do
79
+ before do
80
+ td.create_consumer("Foo")
81
+ .create_provider("Bar")
82
+ .create_consumer_version
83
+ .create_pact
84
+ .create_global_webhook
85
+ .create_consumer_webhook
86
+ .create_provider_webhook
87
+ .create_provider("Wiffle")
88
+ .create_provider_webhook
89
+ end
90
+
91
+ it "returns all the webhooks" do
92
+ integrations = Integration.eager(:webhooks).all
93
+ expect(integrations.first.webhooks.count).to eq 3
94
+ end
95
+ end
58
96
  end
59
97
  end
60
98
  end