pact_broker 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,12 +9,20 @@ services:
9
9
  addons:
10
10
  postgresql: "9.5"
11
11
  env:
12
- - DATABASE_ADAPTER=default RUBYOPT="-W0"
13
- - DATABASE_ADAPTER=postgres RUBYOPT="-W0"
14
- - DATABASE_ADAPTER=mysql RUBYOPT="-W0"
12
+ global:
13
+ - CC_TEST_REPORTER_ID=dc2c30b67c9e2a5309e1aef699c30fdab55ba4f0e4f1beac029ba93e293835db
14
+ - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
15
+ matrix:
16
+ - DATABASE_ADAPTER=default RUBYOPT="-W0"
17
+ - DATABASE_ADAPTER=postgres RUBYOPT="-W0"
18
+ - DATABASE_ADAPTER=mysql RUBYOPT="-W0"
15
19
  before_script:
16
20
  - cp config/database.travis.yml config/database.yml
17
21
  - psql -U postgres -c "CREATE DATABASE pact_broker;"
18
22
  - mysql -e 'CREATE DATABASE pact_broker;'
23
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
24
+ - chmod +x ./cc-test-reporter
19
25
  script:
20
26
  - bundle exec rake
27
+ - if [ "$DATABASE_ADAPTER" == "postgres" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
28
+ - bundle exec bundle-audit update && bundle exec bundle-audit
@@ -2,6 +2,18 @@ Do this to generate your change history
2
2
 
3
3
  $ git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ #### 2.2.0 (2017-07-04)
6
+ * 788c5d0 - chore(gems): Lock rack and red-carpet gem versions for hakiri (Beth Skurrie, Tue Jul 4 10:28:15 2017 +1000)
7
+ * f1abebe - chore(gems): Upgrade pact gems (Beth Skurrie, Tue Jul 4 10:10:55 2017 +1000)
8
+ * 5bccca2 - chore(gems): Upgrade rack-protection and padrino-core gems (Beth Skurrie, Tue Jul 4 10:07:58 2017 +1000)
9
+ * 5c1392d - chore(build): Add code climate test coverage reporter (Beth Skurrie, Tue Jul 4 09:02:09 2017 +1000)
10
+ * 6e73420 - chore(build): Add bundle-audit to build (Beth Skurrie, Tue Jul 4 08:09:49 2017 +1000)
11
+ * de9f493 - fix(pact versions decorator): Corrected use of title and name (Beth Skurrie, Mon Jul 3 19:45:28 2017 +1000)
12
+ * 90d4410 - feat(HTML pact): Add home link to HTML pact (Beth Skurrie, Mon Jul 3 16:57:57 2017 +1000)
13
+ * 4eb2095 - feat(HTML pact): Add tag names next to consumer version number (Beth Skurrie, Mon Jul 3 16:56:56 2017 +1000)
14
+ * 1f66b6d - feat(version): Add HAL links to pacts from version resource (Beth Skurrie, Mon Jul 3 16:34:34 2017 +1000)
15
+ * 3f61fb3 - feat(retrieve latest pact): Add HAL links for latest-untagged and latest/{tag} (Beth Skurrie, Mon Jul 3 16:17:54 2017 +1000)
16
+
5
17
  #### 2.1.1 (2017-07-03)
6
18
  * f7af21a - fix(gemspec) (Beth Skurrie, Mon Jul 3 09:53:02 2017 +1000)
7
19
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'simplecov', :require => false, :group => :test
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Pact Broker
2
-
3
- [![Build Status](https://travis-ci.org/pact-foundation/pact_broker.svg?branch=master)](https://travis-ci.org/pact-foundation/pact_broker) [![Join the chat at https://gitter.im/pact-foundation/pact_broker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pact-foundation/pact_broker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
+ [![Gem Version](https://badge.fury.io/rb/pact_broker.svg)](http://badge.fury.io/rb/pact_broker)
3
+ [![Build Status](https://travis-ci.org/pact-foundation/pact_broker.svg?branch=master)](https://travis-ci.org/pact-foundation/pact_broker) [![Join the chat at https://gitter.im/pact-foundation/pact_broker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pact-foundation/pact_broker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+ [![Code Climate](https://codeclimate.com/github/pact-foundation/pact_broker/badges/gpa.svg)](https://codeclimate.com/github/pact-foundation/pact_broker)
5
+ [![Test Coverage](https://codeclimate.com/github/pact-foundation/pact_broker/badges/coverage.svg)](https://codeclimate.com/github/pact-foundation/pact_broker/coverage)
6
+ [![Issue Count](https://codeclimate.com/github/pact-foundation/pact_broker/badges/issue_count.svg)](https://codeclimate.com/github/pact-foundation/pact_broker)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/pact-foundation/pact_broker.svg)](https://gemnasium.com/github.com/pact-foundation/pact_broker)
4
8
 
5
9
  The Pact Broker provides a repository for consumer driven contracts created using the pact gem.
6
10
 
@@ -44,9 +48,15 @@ If you don't have a [Pact Broker CI Nerf Gun][nerf], you'll probably want to rea
44
48
 
45
49
  ## Documentation
46
50
 
47
- See the [Pact Broker Client](https://github.com/pact-foundation/pact_broker-client) for documentation on how to publish a pact to the Pact Broker, and configure the URLs in the provider project.
51
+ See the [wiki][wiki] for documentation on the Pact Broker.
52
+
53
+ ## Support
48
54
 
49
- See the [wiki](https://github.com/pact-foundation/pact_broker/wiki) for documentation related to the Pact Broker itself.
55
+ * Check the [wiki][wiki] first.
56
+ * See if there is an existing or closed [issue][issues] and raise a new issue if not.
57
+ * See if there is an existing question on [stackoverflow][stackoverflow] tagged with `pact-broker`, and ask a new question if not.
58
+ * Have a chat to us on the Pact [gitter][gitter].
59
+ * Tweet us at [@pact_up][twitter] on the twitters.
50
60
 
51
61
  ### Screenshots
52
62
 
@@ -101,7 +111,7 @@ In a hurry? Hate having to run your own infrastructure? Check out the [Hosted Pa
101
111
 
102
112
  #### Container solutions
103
113
 
104
- You can use the [Pact Broker Docker container][docker] or [Terraform on AWS][terraform]
114
+ You can use the [Pact Broker Docker container][docker] or [Terraform on AWS][terraform]
105
115
 
106
116
  #### Rolling your own
107
117
 
@@ -121,3 +131,8 @@ You can use the [Pact Broker Docker container][docker] or [Terraform on AWS][ter
121
131
  [docker]: https://hub.docker.com/r/dius/pact-broker
122
132
  [terraform]: https://github.com/nadnerb/terraform-pact-broker
123
133
  [hosted]: https://pact.dius.com.au/?utm_source=github&utm_campaign=GITHUB_BROKER&utm_medium=github
134
+ [wiki]: https://github.com/pact-foundation/pact_broker/wiki
135
+ [stackoverflow]: http://stackoverflow.com/questions/tagged/pact-broker
136
+ [twitter]: https://twitter.com/pact_up
137
+ [gitter]: https://gitter.im/realestate-com-au/pact
138
+ [issues]: https://github.com/pact-foundation/pact_broker/issues
@@ -3,7 +3,7 @@
3
3
  1. Increment the version in `./lib/pact_broker/version.rb`
4
4
  2. Update the `CHANGELOG.md` using:
5
5
 
6
- $ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
6
+ $ git log --pretty=format:' * %h - %s (%an, %ad)'
7
7
 
8
8
  3. Add files to git
9
9
 
@@ -37,6 +37,14 @@ module PactBroker
37
37
  }
38
38
  end
39
39
 
40
+ link :'pb:consumer-version' do | options |
41
+ {
42
+ title: "Consumer version",
43
+ name: represented.consumer_version_number,
44
+ href: version_url(options.fetch(:base_url), represented.consumer_version)
45
+ }
46
+ end
47
+
40
48
  link :'pb:provider' do | options |
41
49
  {
42
50
  title: "Provider",
@@ -45,6 +53,7 @@ module PactBroker
45
53
  }
46
54
  end
47
55
 
56
+
48
57
  link :'pb:latest-pact-version' do | options |
49
58
  {
50
59
  title: "Pact",
@@ -54,6 +63,23 @@ module PactBroker
54
63
  }
55
64
  end
56
65
 
66
+ link :'pb:latest-untagged-pact-version' do | options |
67
+ {
68
+ title: "Pact",
69
+ name: "Latest untagged version of this pact",
70
+ href: latest_untagged_pact_url(represented, options.fetch(:base_url))
71
+ }
72
+ end
73
+
74
+ link :'pb:latest-tagged-pact-version' do | options |
75
+ {
76
+ title: "Pact",
77
+ name: "Latest tagged version of this pact",
78
+ href: "#{latest_pact_url(options.fetch(:base_url), represented)}/{tag}",
79
+ templated: true
80
+ }
81
+ end
82
+
57
83
  link :'pb:previous-distinct' do | options |
58
84
  {
59
85
  title: "Pact",
@@ -71,13 +97,6 @@ module PactBroker
71
97
  }
72
98
  end
73
99
 
74
- # link :'pb:pact-versions' do | options |
75
- # {
76
- # title: "All versions of the pact between #{represented.consumer.name} and #{represented.provider.name}",
77
- # href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
78
- # }
79
- # end
80
-
81
100
  link :'pb:pact-webhooks' do | options |
82
101
  {
83
102
  title: "Webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
@@ -87,14 +106,14 @@ module PactBroker
87
106
 
88
107
  link :'pb:tag-prod-version' do | options |
89
108
  {
90
- title: "Tag this version as 'production'",
109
+ title: "PUT to this resource to tag this consumer version as 'production'",
91
110
  href: tags_url(options.fetch(:base_url), represented.consumer_version) + "/prod"
92
111
  }
93
112
  end
94
113
 
95
114
  link :'pb:tag-version' do | options |
96
115
  {
97
- title: "Tag version",
116
+ title: "PUT to this resource to tag this consumer version",
98
117
  href: tags_url(options.fetch(:base_url), represented.consumer_version) + "/{tag}"
99
118
  }
100
119
  end
@@ -8,22 +8,12 @@ module PactBroker
8
8
 
9
9
  module Decorators
10
10
 
11
- class EmbeddedVersionDecorator < BaseDecorator
12
-
13
- property :number
14
-
15
- link :self do | options |
16
- version_url(options[:base_url], represented)
17
- end
18
- end
19
-
20
11
  class PactVersionDecorator < BaseDecorator
21
12
 
22
13
  include Timestamps
23
14
 
24
15
  property :consumer_version, as: :consumerVersion, embedded: true, decorator: EmbeddedVersionDecorator
25
16
 
26
-
27
17
  link :self do | options |
28
18
  {
29
19
  href: pact_url(options[:base_url], represented),
@@ -15,21 +15,24 @@ module PactBroker
15
15
  link :self do | context |
16
16
  {
17
17
  href: context[:resource_url],
18
- title: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
18
+ title: "Pact versions",
19
+ name: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
19
20
  }
20
21
  end
21
22
 
22
23
  link :consumer do | context |
23
24
  {
24
25
  href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:consumer_name])),
25
- title: context[:consumer_name]
26
+ title: "Consumer",
27
+ name: context[:consumer_name]
26
28
  }
27
29
  end
28
30
 
29
31
  link :provider do | context |
30
32
  {
31
33
  href: pacticipant_url(context[:base_url], OpenStruct.new(name: context[:provider_name])),
32
- title: context[:provider_name]
34
+ title: "Provider",
35
+ name: context[:provider_name]
33
36
  }
34
37
  end
35
38
 
@@ -37,7 +40,8 @@ module PactBroker
37
40
  represented.collect do | pact |
38
41
  {
39
42
  :href => pact_url(context[:base_url], pact),
40
- :title => pact.version_and_updated_date
43
+ :title => "Pact",
44
+ :name => pact.version_and_updated_date
41
45
  }
42
46
  end
43
47
  end
@@ -18,6 +18,14 @@ module PactBroker
18
18
  }
19
19
  end
20
20
 
21
+ link :'pb:pacticipant' do | options |
22
+ {
23
+ title: 'Pacticipant',
24
+ name: represented.pacticipant.name,
25
+ href: pacticipant_url(options.fetch(:base_url), represented.pacticipant)
26
+ }
27
+ end
28
+
21
29
  link :'pb:latest-verification-results-where-pacticipant-is-consumer' do | options |
22
30
  {
23
31
  title: "Latest verification results for consumer version",
@@ -25,12 +33,14 @@ module PactBroker
25
33
  }
26
34
  end
27
35
 
28
- link :'pb:pacticipant' do | options |
29
- {
30
- title: 'Pacticipant',
31
- name: represented.pacticipant.name,
32
- href: pacticipant_url(options.fetch(:base_url), represented.pacticipant)
33
- }
36
+ links :'pb:pact-versions' do | context |
37
+ sorted_pacts.collect do | pact |
38
+ {
39
+ title: "Pact",
40
+ name: pact.name,
41
+ href: pact_url(context[:base_url], pact),
42
+ }
43
+ end
34
44
  end
35
45
 
36
46
  curies do | options |
@@ -40,6 +50,12 @@ module PactBroker
40
50
  templated: true
41
51
  }]
42
52
  end
53
+
54
+ private
55
+
56
+ def sorted_pacts
57
+ represented.pact_publications.sort{ |a, b| a.provider_name.downcase <=> b.provider_name.downcase }
58
+ end
43
59
  end
44
60
  end
45
61
  end
@@ -43,6 +43,10 @@ module PactBroker
43
43
  "#{pactigration_base_url(base_url, pact)}/latest"
44
44
  end
45
45
 
46
+ def latest_untagged_pact_url pact, base_url
47
+ "#{pactigration_base_url(base_url, pact)}/latest-untagged"
48
+ end
49
+
46
50
  def latest_pacts_url base_url
47
51
  "#{base_url}/pacts/latest"
48
52
  end
@@ -48,7 +48,7 @@ module PactBroker
48
48
  <ul>
49
49
  <li>
50
50
  <span class='name'>#{@pact.consumer.name} version:</span>
51
- <span class='value'>#{@pact.consumer_version_number}</span>
51
+ <span class='value'>#{@pact.consumer_version_number}#{tags}</span>
52
52
  </li>
53
53
  <li>
54
54
  <span class='name'>Date published:</span>
@@ -57,6 +57,9 @@ module PactBroker
57
57
  <li>
58
58
  <a href=\"#{json_url}\">View in HAL Browser</a>
59
59
  </li>
60
+ <li>
61
+ <a href=\"/\">Home</a>
62
+ </li>
60
63
  </ul>
61
64
  </div>"
62
65
  end
@@ -77,6 +80,14 @@ module PactBroker
77
80
  PactBroker::Api::PactBrokerUrls.pact_url '', @pact
78
81
  end
79
82
 
83
+ def tags
84
+ if @pact.consumer_version_tag_names.any?
85
+ " (#{@pact.consumer_version_tag_names.join(", ")})"
86
+ else
87
+ ""
88
+ end
89
+ end
90
+
80
91
  def markdown
81
92
  Pact::Doc::Markdown::ConsumerContractRenderer.call consumer_contract
82
93
  rescue NotAPactError
@@ -26,6 +26,10 @@ module PactBroker
26
26
  consumer_version.pacticipant
27
27
  end
28
28
 
29
+ def consumer_version_tag_names
30
+ consumer_version.tags.collect(&:name)
31
+ end
32
+
29
33
  def to_s
30
34
  "Pact: consumer=#{consumer.name} provider=#{provider.name}"
31
35
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -29,16 +29,16 @@ Gem::Specification.new do |gem|
29
29
  gem.add_runtime_dependency 'sequel', '~> 4.23'
30
30
  gem.add_runtime_dependency 'webmachine', '1.4.0'
31
31
  gem.add_runtime_dependency 'semver2', '~> 3.4.2'
32
- gem.add_runtime_dependency 'rack', '< 3.0'
33
- gem.add_runtime_dependency 'redcarpet', '~>3.1'
34
- gem.add_runtime_dependency 'pact', '~>1.4'
35
- gem.add_runtime_dependency 'pact-support', '~>0.4', '>=0.4.2'
36
- gem.add_runtime_dependency 'padrino-core', '~>0.12.4'
32
+ gem.add_runtime_dependency 'rack', '~>2.0'
33
+ gem.add_runtime_dependency 'redcarpet', '>=3.3.2', '~>3.3'
34
+ gem.add_runtime_dependency 'pact', '~>1.14'
35
+ gem.add_runtime_dependency 'padrino-core', '~>0.14.1'
37
36
  gem.add_runtime_dependency 'haml', '~>4.0'
38
37
  gem.add_runtime_dependency 'sucker_punch', '~>2.0'
39
- gem.add_runtime_dependency 'rack-protection', '~>1.5'
38
+ gem.add_runtime_dependency 'rack-protection', '~>2.0'
40
39
  gem.add_runtime_dependency 'dry-types', '~> 0.10.3' # https://travis-ci.org/pact-foundation/pact_broker/jobs/249448621
41
40
 
41
+ gem.add_development_dependency 'bundler-audit', '~>0.4'
42
42
  gem.add_development_dependency 'sqlite3'
43
43
  gem.add_development_dependency 'pry-byebug'
44
44
  gem.add_development_dependency 'rake', '~>10.0'
@@ -19,8 +19,9 @@ module PactBroker
19
19
  end
20
20
 
21
21
  let(:options) { { user_options: { base_url: 'http://example.org' } } }
22
+ let(:json) { EmbeddedTagDecorator.new(tag).to_json(options) }
22
23
 
23
- subject { JSON.parse TagDecorator.new(tag).to_json(options), symbolize_names: true }
24
+ subject { JSON.parse json, symbolize_names: true }
24
25
 
25
26
  it "includes the tag name" do
26
27
  expect(subject[:name]).to eq "prod"
@@ -21,11 +21,11 @@ module PactBroker
21
21
  expect(subject[:_links][:self][:href]).to eq "http://example.org/pacticipants/Consumer/versions/1.2.3"
22
22
  end
23
23
 
24
- xit "includes the version number in the link" do
24
+ it "includes the version number in the link" do
25
25
  expect(subject[:_links][:self][:name]).to eq "1.2.3"
26
26
  end
27
27
 
28
- xit "includes its title in the link" do
28
+ it "includes its title in the link" do
29
29
  expect(subject[:_links][:self][:title]).to eq "Version"
30
30
  end
31
31
 
@@ -85,9 +85,18 @@ module PactBroker
85
85
  expect(subject[:_links][:'pb:latest-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest"
86
86
  end
87
87
 
88
- xit "includes a link to the pact versions" do
89
- expect(subject[:_links][:'pb:pact-versions'][:title]).to eq "All versions of the pact between A Consumer and A Provider"
90
- expect(subject[:_links][:'pb:pact-versions'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/versions"
88
+ it "includes a link to the pact version" do
89
+ expect(subject[:_links][:'pb:consumer-version'][:title]).to eq "Consumer version"
90
+ expect(subject[:_links][:'pb:consumer-version'][:name]).to eq "1234"
91
+ expect(subject[:_links][:'pb:consumer-version'][:href]).to eq "http://example.org/pacticipants/A%20Consumer/versions/1234"
92
+ end
93
+
94
+ it "includes a link to the latest untagged version" do
95
+ expect(subject[:_links][:'pb:latest-untagged-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest-untagged"
96
+ end
97
+
98
+ it "includes a link to the latest tagged version" do
99
+ expect(subject[:_links][:'pb:latest-tagged-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest/{tag}"
91
100
  end
92
101
 
93
102
  it "includes a link to publish a verification" do
@@ -9,9 +9,13 @@ module PactBroker
9
9
  let(:version) do
10
10
  TestDataBuilder.new
11
11
  .create_consumer("Consumer")
12
+ .create_provider("providerA")
12
13
  .create_consumer_version("1.2.3")
13
14
  .create_consumer_version_tag("prod")
14
- PactBroker::Versions::Repository.new.find_by_pacticipant_name_and_number "Consumer", "1.2.3"
15
+ .create_pact
16
+ .create_provider("ProviderB")
17
+ .create_pact
18
+ .and_return(:consumer_version)
15
19
  end
16
20
 
17
21
  let(:options) { { user_options: { base_url: 'http://example.org' } } }
@@ -43,10 +47,17 @@ module PactBroker
43
47
  expect(subject[:_embedded][:tags].first[:name]).to eq "prod"
44
48
  end
45
49
 
50
+ it "includes a list of sorted pacts" do
51
+ expect(subject[:_links][:'pb:pact-versions']).to be_instance_of(Array)
52
+ expect(subject[:_links][:'pb:pact-versions'].first[:href]).to include ("1.2.3")
53
+ expect(subject[:_links][:'pb:pact-versions'].first[:name]).to include ("Pact between")
54
+ expect(subject[:_links][:'pb:pact-versions'].first[:name]).to include ("providerA")
55
+ expect(subject[:_links][:'pb:pact-versions'].last[:name]).to include ("ProviderB")
56
+ end
57
+
46
58
  it "includes a link to the latest verification results for the pacts for this version" do
47
59
  expect(subject[:_links][:'pb:latest-verification-results-where-pacticipant-is-consumer'][:href]).to match(%r{http://.*/verification-results/.*/latest})
48
60
  end
49
-
50
61
  end
51
62
  end
52
63
  end