pact_broker 2.35.0 → 2.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/db/migrations/000029_create_latest_tagged_pact_publications.rb +2 -0
  4. data/lib/pact_broker/api.rb +3 -0
  5. data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +42 -0
  6. data/lib/pact_broker/api/decorators/extended_verification_decorator.rb +16 -0
  7. data/lib/pact_broker/api/decorators/pact_decorator.rb +6 -3
  8. data/lib/pact_broker/api/decorators/verification_decorator.rb +4 -0
  9. data/lib/pact_broker/api/pact_broker_urls.rb +12 -0
  10. data/lib/pact_broker/api/resources/dashboard.rb +1 -3
  11. data/lib/pact_broker/api/resources/index.rb +5 -0
  12. data/lib/pact_broker/api/resources/latest_verification_for_pact.rb +19 -0
  13. data/lib/pact_broker/api/resources/latest_verifications_for_consumer_version.rb +0 -1
  14. data/lib/pact_broker/api/resources/metrics.rb +21 -0
  15. data/lib/pact_broker/api/resources/pact.rb +8 -1
  16. data/lib/pact_broker/api/resources/pact_versions.rb +0 -1
  17. data/lib/pact_broker/api/resources/verification.rb +14 -1
  18. data/lib/pact_broker/domain/pact.rb +1 -2
  19. data/lib/pact_broker/domain/verification.rb +5 -3
  20. data/lib/pact_broker/index/service.rb +16 -1
  21. data/lib/pact_broker/matrix/aggregated_row.rb +14 -1
  22. data/lib/pact_broker/matrix/repository.rb +29 -25
  23. data/lib/pact_broker/matrix/resolved_selector.rb +3 -1
  24. data/lib/pact_broker/matrix/row.rb +6 -2
  25. data/lib/pact_broker/metrics/service.rb +56 -0
  26. data/lib/pact_broker/pacts/all_pact_publications.rb +8 -1
  27. data/lib/pact_broker/pacts/pact_publication.rb +9 -2
  28. data/lib/pact_broker/services.rb +5 -0
  29. data/lib/pact_broker/ui/views/index/show-with-tags.haml +2 -2
  30. data/lib/pact_broker/ui/views/matrix/show.haml +2 -2
  31. data/lib/pact_broker/verifications/repository.rb +4 -0
  32. data/lib/pact_broker/verifications/service.rb +4 -0
  33. data/lib/pact_broker/version.rb +1 -1
  34. data/public/javascripts/clipboard.js +2 -2
  35. data/spec/features/get_latest_verification_for_pact_spec.rb +42 -0
  36. data/spec/features/get_pact_versions_spec.rb +0 -5
  37. data/spec/features/metrics_spec.rb +23 -0
  38. data/spec/lib/pact_broker/api/decorators/extended_pact_decorator_spec.rb +61 -0
  39. data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +2 -1
  40. data/spec/lib/pact_broker/api/decorators/verification_decorator_spec.rb +4 -1
  41. data/spec/lib/pact_broker/api/decorators/verification_summary_decorator_spec.rb +3 -1
  42. data/spec/lib/pact_broker/index/service_spec.rb +29 -4
  43. data/spec/lib/pact_broker/matrix/aggregated_row_spec.rb +23 -2
  44. data/spec/lib/pact_broker/matrix/deployment_status_summary_spec.rb +2 -0
  45. data/spec/lib/pact_broker/matrix/repository_query_limit_spec.rb +44 -0
  46. data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +21 -3
  47. metadata +15 -2
@@ -103,6 +103,7 @@ module PactBroker
103
103
  specified_pacticipant_names.include?(consumer_name)
104
104
  end
105
105
 
106
+ # It would be nicer to do this in the SQL, but it requires time that I don't have at the moment
106
107
  def apply_latestby options, selectors, lines
107
108
  return lines unless options[:latestby]
108
109
  group_by_columns = case options[:latestby]
@@ -119,6 +120,7 @@ module PactBroker
119
120
  .flatten
120
121
  end
121
122
 
123
+ # It would be nicer to do this in the SQL, but it requires time that I don't have at the moment
122
124
  def remove_overwritten_revisions lines
123
125
  latest_revisions_keys = {}
124
126
  latest_revisions = []
@@ -143,7 +145,7 @@ module PactBroker
143
145
  end
144
146
 
145
147
  def resolve_selectors(specified_selectors, options)
146
- resolved_specified_selectors = resolve_versions_and_add_ids(specified_selectors, :specified)
148
+ resolved_specified_selectors = resolve_versions_and_add_ids(specified_selectors, :specified, options[:latestby])
147
149
  if options[:latest] || options[:tag]
148
150
  add_inferred_selectors(resolved_specified_selectors, options)
149
151
  else
@@ -152,19 +154,19 @@ module PactBroker
152
154
  end
153
155
 
154
156
  # Find the version number for selectors with the latest and/or tag specified
155
- def resolve_versions_and_add_ids(selectors, selector_type)
157
+ def resolve_versions_and_add_ids(selectors, selector_type, latestby)
156
158
  selectors.collect do | selector |
157
159
  pacticipant = PactBroker::Domain::Pacticipant.find(name: selector[:pacticipant_name])
158
160
  versions = find_versions_for_selector(selector)
159
- build_selectors_for_pacticipant_and_versions(pacticipant, versions, selector, selector_type)
161
+ build_selectors_for_pacticipant_and_versions(pacticipant, versions, selector, selector_type, latestby)
160
162
  end.flatten
161
163
  end
162
164
 
163
- def build_selectors_for_pacticipant_and_versions(pacticipant, versions, original_selector, selector_type)
165
+ def build_selectors_for_pacticipant_and_versions(pacticipant, versions, original_selector, selector_type, latestby)
164
166
  if versions
165
167
  versions.collect do | version |
166
168
  if version
167
- selector_for_version(pacticipant, version, original_selector, selector_type)
169
+ selector_for_version(pacticipant, version, original_selector, selector_type, latestby)
168
170
  else
169
171
  selector_for_non_existing_version(pacticipant, original_selector, selector_type)
170
172
  end
@@ -192,23 +194,6 @@ module PactBroker
192
194
  end
193
195
  end
194
196
 
195
- def add_ids_to_selector(selector)
196
- if selector[:pacticipant_name]
197
- pacticipant = PactBroker::Domain::Pacticipant.find(name: selector[:pacticipant_name])
198
- selector[:pacticipant_id] = pacticipant ? pacticipant.id : nil
199
- end
200
-
201
- if selector[:pacticipant_name] && selector[:pacticipant_version_number] && !selector[:pacticipant_version_id]
202
- version = version_repository.find_by_pacticipant_name_and_number(selector[:pacticipant_name], selector[:pacticipant_version_number])
203
- selector[:pacticipant_version_id] = version ? version.id : nil
204
- end
205
-
206
- if !selector.key?(:pacticipant_version_id)
207
- selector[:pacticipant_version_id] = nil
208
- end
209
- selector
210
- end
211
-
212
197
  # When only one selector is specified, (eg. checking to see if Foo version 2 can be deployed to prod),
213
198
  # need to look up all integrated pacticipants, and determine their relevant (eg. latest prod) versions
214
199
  def add_inferred_selectors(resolved_specified_selectors, options)
@@ -228,7 +213,7 @@ module PactBroker
228
213
  selector[:latest] = options[:latest] if options[:latest]
229
214
  selector
230
215
  end
231
- resolve_versions_and_add_ids(selectors, :inferred)
216
+ resolve_versions_and_add_ids(selectors, :inferred, options[:latestby])
232
217
  end
233
218
 
234
219
  def all_pacticipant_names_in_specified_matrix(selectors)
@@ -242,8 +227,27 @@ module PactBroker
242
227
  ResolvedSelector.for_pacticipant_and_non_existing_version(pacticipant, original_selector, selector_type)
243
228
  end
244
229
 
245
- def selector_for_version(pacticipant, version, original_selector, selector_type)
246
- ResolvedSelector.for_pacticipant_and_version(pacticipant, version, original_selector, selector_type)
230
+ def selector_for_version(pacticipant, version, original_selector, selector_type, latestby)
231
+ pact_publication_ids, verification_ids = nil, nil
232
+
233
+ # Querying for the "pre-filtered" pact publications and verifications directly, rather than just using the consumer
234
+ # and provider versions allows us to remove the "overwritten" pact revisions and verifications from the
235
+ # matrix result set, making the final matrix query more efficient and stopping the query limit from
236
+ # removing relevant data (eg. https://github.com/pact-foundation/pact_broker-client/issues/53)
237
+ if latestby
238
+ pact_publication_ids = PactBroker::Pacts::LatestPactPublicationsByConsumerVersion
239
+ .select(:id)
240
+ .where(consumer_version_id: version.id)
241
+ .collect{ |pact_publication| pact_publication[:id] }
242
+
243
+ verification_ids = PactBroker::Verifications::LatestVerificationIdForPactVersionAndProviderVersion
244
+ .select(:verification_id)
245
+ .distinct
246
+ .where(provider_version_id: version.id)
247
+ .collect{ |pact_publication| pact_publication[:verification_id] }
248
+ end
249
+
250
+ ResolvedSelector.for_pacticipant_and_version(pacticipant, version, pact_publication_ids, verification_ids, original_selector, selector_type)
247
251
  end
248
252
 
249
253
  def selector_without_version(pacticipant, selector_type)
@@ -23,11 +23,13 @@ module PactBroker
23
23
  )
24
24
  end
25
25
 
26
- def self.for_pacticipant_and_version(pacticipant, version, original_selector, type)
26
+ def self.for_pacticipant_and_version(pacticipant, version, pact_publication_ids = [], verification_ids = [], original_selector, type)
27
27
  ResolvedSelector.new(
28
28
  pacticipant_id: pacticipant.id,
29
29
  pacticipant_name: pacticipant.name,
30
30
  pacticipant_version_id: version.id,
31
+ pact_publication_ids: pact_publication_ids,
32
+ verification_ids: verification_ids,
31
33
  pacticipant_version_number: version.number,
32
34
  latest: original_selector[:latest],
33
35
  tag: original_selector[:tag],
@@ -67,7 +67,9 @@ module PactBroker
67
67
  end
68
68
 
69
69
  def self.consumer_and_maybe_consumer_version_match_selector(s)
70
- if s[:pacticipant_version_id]
70
+ if s[:pact_publication_ids]
71
+ Sequel.&(pact_publication_id: s[:pact_publication_ids])
72
+ elsif s[:pacticipant_version_id]
71
73
  Sequel.&(consumer_id: s[:pacticipant_id], consumer_version_id: s[:pacticipant_version_id])
72
74
  else
73
75
  Sequel.&(consumer_id: s[:pacticipant_id])
@@ -75,7 +77,9 @@ module PactBroker
75
77
  end
76
78
 
77
79
  def self.provider_and_maybe_provider_version_match_selector(s)
78
- if s[:pacticipant_version_id]
80
+ if s[:verification_ids]
81
+ Sequel.&(verification_id: s[:verification_ids])
82
+ elsif s[:pacticipant_version_id]
79
83
  Sequel.&(provider_id: s[:pacticipant_id], provider_version_id: s[:pacticipant_version_id])
80
84
  else
81
85
  Sequel.&(provider_id: s[:pacticipant_id])
@@ -0,0 +1,56 @@
1
+ require 'pact_broker/pacts/pact_publication'
2
+ require 'pact_broker/pacts/pact_version'
3
+ require 'pact_broker/domain/pacticipant'
4
+ require 'pact_broker/integrations/integration'
5
+ require 'pact_broker/domain/verification'
6
+ require 'pact_broker/domain/version'
7
+ require 'pact_broker/api/decorators/format_date_time'
8
+ require 'pact_broker/webhooks/webhook'
9
+ require 'pact_broker/webhooks/triggered_webhook'
10
+ require 'pact_broker/webhooks/execution'
11
+
12
+ module PactBroker
13
+ module Metrics
14
+ module Service
15
+ include PactBroker::Api::Decorators::FormatDateTime
16
+
17
+ extend self
18
+
19
+ def metrics
20
+ {
21
+ pacticipants: {
22
+ count: PactBroker::Domain::Pacticipant.count
23
+ },
24
+ integrations: {
25
+ count: PactBroker::Integrations::Integration.count
26
+ },
27
+ pactPublications: {
28
+ count: PactBroker::Pacts::PactPublication.count,
29
+ first: format_date_time(PactBroker::Pacts::PactPublication.order(:id).first&.created_at),
30
+ last: format_date_time(PactBroker::Pacts::PactPublication.order(:id).last&.created_at)
31
+ },
32
+ pactVersions: {
33
+ count: PactBroker::Pacts::PactVersion.count
34
+ },
35
+ verificationResults: {
36
+ count: PactBroker::Domain::Verification.count,
37
+ first: format_date_time(PactBroker::Domain::Verification.order(:id).first.created_at),
38
+ last: format_date_time(PactBroker::Domain::Verification.order(:id).last.created_at)
39
+ },
40
+ pacticipantVersions: {
41
+ count: PactBroker::Domain::Version.count
42
+ },
43
+ webhooks: {
44
+ count: PactBroker::Webhooks::Webhook.count
45
+ },
46
+ triggeredWebhooks: {
47
+ count: PactBroker::Webhooks::TriggeredWebhook.count
48
+ },
49
+ webhookExecutions: {
50
+ count: PactBroker::Webhooks::Execution.count
51
+ }
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
@@ -101,7 +101,14 @@ module PactBroker
101
101
  consumer_version_number: consumer_version_number,
102
102
  revision_number: revision_number,
103
103
  pact_version_sha: pact_version_sha,
104
- created_at: created_at)
104
+ created_at: created_at,
105
+ head_tag_names: head_tag_names)
106
+ end
107
+
108
+ def head_tag_names
109
+ # Avoid circular dependency
110
+ require 'pact_broker/pacts/latest_tagged_pact_publications'
111
+ LatestTaggedPactPublications.where(id: id).select(:tag_name).collect{|t| t[:tag_name]}
105
112
  end
106
113
 
107
114
  def to_domain_with_content
@@ -31,10 +31,16 @@ module PactBroker
31
31
  self.revision_number ||= 1
32
32
  end
33
33
 
34
- def latest_tag_names
34
+ # The names of the tags for which this pact is the latest pact with that tag
35
+ # (ie. it is not necessarily the pact for the latest consumer version with the given tag)
36
+ def head_tag_names
35
37
  LatestTaggedPactPublications.where(id: id).select(:tag_name).collect{|t| t[:tag_name]}
36
38
  end
37
39
 
40
+ def consumer_version_tags
41
+ consumer_version.tags
42
+ end
43
+
38
44
  def latest_verification
39
45
  pact_version.latest_verification
40
46
  end
@@ -50,7 +56,8 @@ module PactBroker
50
56
  json_content: pact_version.content,
51
57
  pact_version_sha: pact_version.sha,
52
58
  latest_verification: latest_verification,
53
- created_at: created_at
59
+ created_at: created_at,
60
+ head_tag_names: head_tag_names
54
61
  )
55
62
  end
56
63
 
@@ -71,5 +71,10 @@ module PactBroker
71
71
  require 'pact_broker/webhooks/trigger_service'
72
72
  Webhooks::TriggerService
73
73
  end
74
+
75
+ def metrics_service
76
+ require 'pact_broker/metrics/service'
77
+ Metrics::Service
78
+ end
74
79
  end
75
80
  end
@@ -41,7 +41,7 @@
41
41
  %td.consumer-version-number
42
42
  %div.clippable
43
43
  = escape_html(index_item.consumer_version_number)
44
- %button.clippy.hidden{ title: "Copy to clipboard" }
44
+ %button.clippy.invisible{ title: "Copy to clipboard" }
45
45
  %span.glyphicon.glyphicon-copy
46
46
  - if index_item.latest?
47
47
  .tag.label.label-success
@@ -60,7 +60,7 @@
60
60
  %td.provider-version-number
61
61
  %div.clippable
62
62
  = escape_html(index_item.provider_version_number)
63
- %button.clippy.hidden{ title: "Copy to clipboard" }
63
+ %button.clippy.invisible{ title: "Copy to clipboard" }
64
64
  %span.glyphicon.glyphicon-copy
65
65
  - index_item.provider_version_latest_tag_names.each do | tag_name |
66
66
  .tag.label.label-primary
@@ -106,7 +106,7 @@
106
106
  %div.clippable
107
107
  %a{href: line.consumer_version_number_url}
108
108
  = line.display_consumer_version_number
109
- %button.clippy.hidden{ title: "Copy to clipboard" }
109
+ %button.clippy.invisible{ title: "Copy to clipboard" }
110
110
  %span.glyphicon.glyphicon-copy
111
111
  - line.latest_consumer_version_tags.each do | tag |
112
112
  .tag-parent{"title": tag.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
@@ -132,7 +132,7 @@
132
132
  %div.clippable
133
133
  %a{href: line.provider_version_number_url}
134
134
  = line.display_provider_version_number
135
- %button.clippy.hidden{ title: "Copy to clipboard" }
135
+ %button.clippy.invisible{ title: "Copy to clipboard" }
136
136
  %span.glyphicon.glyphicon-copy
137
137
  - line.latest_provider_version_tags.each do | tag |
138
138
  .tag-parent{"title": tag.tooltip, "data-toggle": "tooltip", "data-placement": "right"}
@@ -54,6 +54,10 @@ module PactBroker
54
54
  .verification_number(verification_number).single_record
55
55
  end
56
56
 
57
+ def find_latest_for_pact(pact)
58
+ PactBroker::Pacts::PactPublication.where(id: pact.id).single_record.latest_verification
59
+ end
60
+
57
61
  def search_for_latest consumer_name, provider_name
58
62
  query = LatestVerificationForPactVersion
59
63
  .select_all_qualified
@@ -49,6 +49,10 @@ module PactBroker
49
49
  verification_repository.find(params.fetch(:consumer_name), params.fetch(:provider_name), params.fetch(:pact_version_sha), params.fetch(:verification_number))
50
50
  end
51
51
 
52
+ def find_latest_for_pact(pact)
53
+ verification_repository.find_latest_for_pact(pact)
54
+ end
55
+
52
56
  def find_by_id id
53
57
  PactBroker::Domain::Verification.find(id: id)
54
58
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.35.0'
2
+ VERSION = '2.36.0'
3
3
  end
@@ -4,7 +4,7 @@
4
4
  * @example in Haml
5
5
  * %div.clippable
6
6
  * = Text to be copied
7
- * %button.clippy.hidden{ title: "Copy to clipboard" }
7
+ * %button.clippy.invisible{ title: "Copy to clipboard" }
8
8
  * %span.glyphicon.glyphicon-copy
9
9
  */
10
10
 
@@ -17,7 +17,7 @@ function initializeClipper(selector) {
17
17
  const elements = $(selector);
18
18
 
19
19
  elements.hover(function() {
20
- $(this).children(".clippy").toggleClass("hidden");
20
+ $(this).children(".clippy").toggleClass("invisible");
21
21
  });
22
22
 
23
23
  elements
@@ -0,0 +1,42 @@
1
+ require 'spec/support/test_data_builder'
2
+
3
+ describe "Get latest verification for pact" do
4
+ before do
5
+ td
6
+ .create_consumer("Consumer")
7
+ .create_consumer_version("1.2.3")
8
+ .create_provider("Another provider")
9
+ .create_pact
10
+ .create_verification(number: 1, provider_version: "5")
11
+ .create_provider("Provider")
12
+ .create_pact
13
+ .create_verification(number: 1, provider_version: "3")
14
+ .create_verification(number: 2, provider_version: "4")
15
+ end
16
+
17
+ let(:last_response_body) { JSON.parse(subject.body, symbolize_names: true) }
18
+ let(:content_type) { "application/vnd.pactbrokerextended.v1+json" }
19
+
20
+ subject { get(path, nil, "HTTP_ACCEPT" => content_type) }
21
+
22
+ context "by pact version" do
23
+ let!(:path) { "/pacts/provider/Provider/consumer/Consumer/pact-version/#{td.pact.pact_version_sha}/verification-results/latest" }
24
+
25
+ it "returns a 200 OK" do
26
+ expect(subject.status).to eq 200
27
+ expect(subject.headers['Content-Type']).to include content_type
28
+ end
29
+
30
+ it "returns the verification" do
31
+ expect(last_response_body[:providerApplicationVersion]).to eq "4"
32
+ end
33
+ end
34
+
35
+ context "by consumer version" do
36
+ let(:path) { "/pacts/provider/Provider/consumer/Consumer/version/1.2.3/verification-results/latest" }
37
+
38
+ it "returns the verification" do
39
+ expect(last_response_body[:providerApplicationVersion]).to eq "4"
40
+ end
41
+ end
42
+ end
@@ -1,14 +1,12 @@
1
1
  require 'spec/support/test_data_builder'
2
2
 
3
3
  describe "Get pact versions" do
4
-
5
4
  let(:path) { "/pacts/provider/Provider/consumer/Consumer/versions" }
6
5
  let(:last_response_body) { JSON.parse(subject.body, symbolize_names: true) }
7
6
 
8
7
  subject { get path; last_response }
9
8
 
10
9
  context "when the pacts exist" do
11
-
12
10
  before do
13
11
  TestDataBuilder.new
14
12
  .create_provider("Provider")
@@ -26,14 +24,11 @@ describe "Get pact versions" do
26
24
  it "returns a list of links to the pacts" do
27
25
  expect(last_response_body[:_links][:"pact-versions"].size).to eq 2
28
26
  end
29
-
30
27
  end
31
28
 
32
29
  context "when the pacts do not exist" do
33
-
34
30
  it "returns a 404 response" do
35
31
  expect(subject).to be_a_404_response
36
32
  end
37
-
38
33
  end
39
34
  end
@@ -0,0 +1,23 @@
1
+ describe "get metrics" do
2
+ let(:path) { "/metrics"}
3
+ let(:json_response_body) { JSON.parse(subject.body, symbolize_names: true) }
4
+
5
+ subject { get(path) }
6
+
7
+ before do
8
+ TestDataBuilder.new
9
+ .create_consumer("Consumer")
10
+ .create_provider("Provider")
11
+ .create_consumer_version("1.2.3")
12
+ .create_consumer_version_tag("prod")
13
+ .create_pact
14
+ .create_verification(provider_version: "4.5.6")
15
+ .create_webhook
16
+ .create_triggered_webhook
17
+ .create_webhook_execution
18
+ end
19
+
20
+ it "returns some metrics" do
21
+ expect(json_response_body).to be_instance_of(Hash)
22
+ end
23
+ end
@@ -0,0 +1,61 @@
1
+ require 'pact_broker/api/decorators/extended_pact_decorator'
2
+
3
+ module PactBroker
4
+ module Api
5
+ module Decorators
6
+ describe ExtendedPactDecorator do
7
+ before do
8
+ allow(decorator).to receive(:templated_diff_url).and_return('templated-diff-url')
9
+ allow(decorator).to receive(:verification_publication_url).and_return('verification-publication-url')
10
+ end
11
+ let(:content_hash) {
12
+ {
13
+ 'consumer' => {'name' => 'Consumer'},
14
+ 'provider' => {'name' => 'Provider'},
15
+ 'interactions' => [],
16
+ 'metadata' => {}
17
+ }
18
+ }
19
+
20
+ let(:base_url) { 'http://example.org' }
21
+ let(:created_at) { Time.new(2014, 3, 4) }
22
+ let(:pact) { double('pact',
23
+ content_hash: content_hash,
24
+ created_at: created_at,
25
+ consumer: consumer,
26
+ consumer_name: consumer.name,
27
+ provider: provider,
28
+ provider_name: provider.name,
29
+ consumer_version: consumer_version,
30
+ consumer_version_number: '1234',
31
+ pact_version_sha: '9999',
32
+ revision_number: 2,
33
+ name: 'A Pact',
34
+ head_tag_names: head_tag_names
35
+ )}
36
+ let(:head_tag_names) { ['prod'] }
37
+ let(:consumer) { instance_double(PactBroker::Domain::Pacticipant, name: 'A Consumer')}
38
+ let(:provider) { instance_double(PactBroker::Domain::Pacticipant, name: 'A Provider')}
39
+ let(:consumer_version) { instance_double(PactBroker::Domain::Version, number: '1234', pacticipant: consumer)}
40
+ let(:metadata) { "abcd" }
41
+ let(:decorator) { ExtendedPactDecorator.new(pact) }
42
+ let(:json) { decorator.to_json(user_options: { base_url: base_url, metadata: metadata }) }
43
+ subject { JSON.parse(json, symbolize_names: true) }
44
+
45
+ it "includes an array of tags" do
46
+ expect(subject[:_embedded][:tags].first).to include name: 'prod', latest: true
47
+ # Can't seem to stub the verification_publication_url method on the TagDecorator
48
+ expect(subject[:_embedded][:tags].first[:_links][:'pb:latest-pact'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest/prod"
49
+ end
50
+
51
+ it "includes the pact contents under the contract key" do
52
+ expect(subject[:contract]).to eq JSON.parse(content_hash.to_json, symbolize_names: true)
53
+ end
54
+
55
+ it "does not include the contract contents in the root" do
56
+ expect(subject).to_not have_key(:interactions)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end