pact_broker 1.3.1 → 1.3.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +12 -0
  4. data/db/migrations/07_increase_json_content_length.rb +3 -7
  5. data/db/migrations/15_add_value_to_tag.rb.wip +5 -0
  6. data/db/migrations/15_create_pact_version_content.rb +13 -0
  7. data/db/migrations/16_add_pact_content_foreign_key_to_pacts.rb +10 -0
  8. data/db/migrations/17_migrate_json_content_to_pact_version_content_table.rb +14 -0
  9. data/db/migrations/18_drop_json_content_column_from_pacts.rb +14 -0
  10. data/db/migrations/19_make_pact_version_content_sha_not_nullable.rb +10 -0
  11. data/db/migrations/20_add_pact_version_content_sha_to_all_pacts_view.rb +18 -0
  12. data/db/migrations/21_recreate_latest_pacts_view.rb +21 -0
  13. data/db/migrations/migration_helper.rb +15 -0
  14. data/db/pact_broker_database.sqlite3 +0 -0
  15. data/example/config.ru +5 -1
  16. data/example/pact_broker_database.sqlite3 +0 -0
  17. data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +1 -1
  18. data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +1 -1
  19. data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +1 -1
  20. data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +1 -1
  21. data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +1 -1
  22. data/lib/pact_broker/api/decorators/webhook_decorator.rb +2 -2
  23. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +1 -1
  24. data/lib/pact_broker/api/resources/pact.rb +8 -1
  25. data/lib/pact_broker/api/resources/pact_webhooks.rb +1 -1
  26. data/lib/pact_broker/api/resources/pacticipants.rb +2 -2
  27. data/lib/pact_broker/db/validate_encoding.rb +22 -0
  28. data/lib/pact_broker/doc/views/pacticipants.markdown +3 -1
  29. data/lib/pact_broker/domain.rb +5 -0
  30. data/lib/pact_broker/{models → domain}/group.rb +1 -1
  31. data/lib/pact_broker/{models → domain}/order_versions.rb +2 -2
  32. data/lib/pact_broker/{models → domain}/pact.rb +1 -1
  33. data/lib/pact_broker/{models → domain}/pacticipant.rb +1 -1
  34. data/lib/pact_broker/{models → domain}/relationship.rb +1 -1
  35. data/lib/pact_broker/{models → domain}/tag.rb +2 -2
  36. data/lib/pact_broker/{models → domain}/version.rb +3 -3
  37. data/lib/pact_broker/{models → domain}/webhook.rb +2 -2
  38. data/lib/pact_broker/{models → domain}/webhook_execution_result.rb +1 -1
  39. data/lib/pact_broker/{models → domain}/webhook_request.rb +3 -3
  40. data/lib/pact_broker/{models → domain}/webhook_request_header.rb +1 -1
  41. data/lib/pact_broker/functions/find_potential_duplicate_pacticipant_names.rb +1 -1
  42. data/lib/pact_broker/functions/groupify.rb +2 -2
  43. data/lib/pact_broker/locale/en.yml +1 -0
  44. data/lib/pact_broker/pacts/all_pacts.rb +82 -0
  45. data/lib/pact_broker/pacts/database_model.rb +35 -0
  46. data/lib/pact_broker/pacts/latest_pacts.rb +11 -0
  47. data/lib/pact_broker/pacts/pact_version_content.rb +11 -0
  48. data/lib/pact_broker/pacts/repository.rb +106 -0
  49. data/lib/pact_broker/repositories.rb +3 -3
  50. data/lib/pact_broker/repositories/pacticipant_repository.rb +6 -6
  51. data/lib/pact_broker/repositories/tag_repository.rb +3 -3
  52. data/lib/pact_broker/repositories/version_repository.rb +5 -5
  53. data/lib/pact_broker/repositories/webhook.rb +89 -0
  54. data/lib/pact_broker/repositories/webhook_repository.rb +9 -94
  55. data/lib/pact_broker/services/pact_service.rb +4 -0
  56. data/lib/pact_broker/services/pacticipant_service.rb +3 -3
  57. data/lib/pact_broker/ui.rb +7 -0
  58. data/lib/pact_broker/ui/controllers/clusters.rb +1 -1
  59. data/lib/pact_broker/ui/controllers/relationships.rb +1 -1
  60. data/lib/pact_broker/ui/view_models/relationship.rb +1 -1
  61. data/lib/pact_broker/ui/view_models/relationships.rb +12 -3
  62. data/lib/pact_broker/ui/views/relationships/show.haml +2 -0
  63. data/lib/pact_broker/version.rb +1 -1
  64. data/public/stylesheets/relationships.css +5 -0
  65. data/spec/features/create_webhook_spec.rb +77 -0
  66. data/spec/features/delete_pact_spec.rb +28 -0
  67. data/spec/features/publish_pact_spec.rb +58 -0
  68. data/spec/features/update_pacticipant_spec.rb +26 -0
  69. data/spec/fixtures/update_pacticipant.json +5 -0
  70. data/spec/fixtures/updated_pacticipant.json +11 -0
  71. data/spec/integration/app_spec.rb +1 -4
  72. data/spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb +1 -1
  73. data/spec/lib/pact_broker/api/decorators/pact_collection_decorator_spec.rb +5 -5
  74. data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +3 -3
  75. data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +3 -3
  76. data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +2 -2
  77. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +6 -6
  78. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +2 -2
  79. data/spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb +2 -2
  80. data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +1 -1
  81. data/spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb +1 -1
  82. data/spec/lib/pact_broker/api/resources/pact_spec.rb +34 -1
  83. data/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb +3 -3
  84. data/spec/lib/pact_broker/api/resources/pacticipants_spec.rb +1 -1
  85. data/spec/lib/pact_broker/api/resources/tag_spec.rb +1 -1
  86. data/spec/lib/pact_broker/db/validate_encoding_spec.rb +66 -0
  87. data/spec/lib/pact_broker/{models → domain}/group_spec.rb +5 -5
  88. data/spec/lib/pact_broker/{models → domain}/order_versions_spec.rb +4 -4
  89. data/spec/lib/pact_broker/{models → domain}/pacticipant_spec.rb +2 -2
  90. data/spec/lib/pact_broker/{models → domain}/webhook_request_spec.rb +2 -2
  91. data/spec/lib/pact_broker/{models → domain}/webhook_spec.rb +3 -3
  92. data/spec/lib/pact_broker/functions/groupify_spec.rb +10 -10
  93. data/spec/lib/pact_broker/{repositories/pact_repository_spec.rb → pacts/repository_spec.rb} +128 -28
  94. data/spec/lib/pact_broker/repositories/webhook_repository_spec.rb +3 -3
  95. data/spec/lib/pact_broker/services/group_service_spec.rb +4 -4
  96. data/spec/lib/pact_broker/services/pact_service_spec.rb +4 -4
  97. data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +11 -11
  98. data/spec/lib/pact_broker/services/webhook_service_spec.rb +5 -5
  99. data/spec/lib/pact_broker/ui/controllers/relationships_spec.rb +3 -3
  100. data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +8 -8
  101. data/spec/lib/pact_broker/ui/view_models/relationships_spec.rb +28 -5
  102. data/spec/support/provider_state_builder.rb +17 -17
  103. data/tasks/db.rake +1 -2
  104. metadata +59 -35
  105. data/lib/pact_broker/jobs/after_pact_save.rb +0 -13
  106. data/lib/pact_broker/models.rb +0 -5
  107. data/lib/pact_broker/repositories/pact.rb +0 -29
  108. data/lib/pact_broker/repositories/pact_repository.rb +0 -140
  109. data/spec/integration/endpoints/pact_put_spec.rb +0 -59
  110. data/spec/integration/endpoints/pact_webhooks_spec.rb +0 -96
@@ -15,7 +15,7 @@ module PactBroker
15
15
  let(:all_pacts) { [pact_4, pact_3, pact_2, pact_1]}
16
16
 
17
17
  before do
18
- allow_any_instance_of(Repositories::PactRepository).to receive(:find_all_pacts_between).and_return(all_pacts)
18
+ allow_any_instance_of(Pacts::Repository).to receive(:find_all_pacts_between).and_return(all_pacts)
19
19
  end
20
20
 
21
21
  subject { PactService.find_distinct_pacts_between 'consumer', :and => 'provider' }
@@ -29,16 +29,16 @@ module PactBroker
29
29
  describe "#pact_has_changed_since_previous_version?" do
30
30
 
31
31
  let(:json_content) { { 'some' => 'json'}.to_json }
32
- let(:pact) { instance_double(PactBroker::Models::Pact, json_content: json_content)}
32
+ let(:pact) { instance_double(PactBroker::Domain::Pact, json_content: json_content)}
33
33
 
34
34
  before do
35
- allow_any_instance_of(Repositories::PactRepository).to receive(:find_previous_pact).and_return(previous_pact)
35
+ allow_any_instance_of(Pacts::Repository).to receive(:find_previous_pact).and_return(previous_pact)
36
36
  end
37
37
 
38
38
  subject { PactService.pact_has_changed_since_previous_version? pact }
39
39
 
40
40
  context "when a previous pact is found" do
41
- let(:previous_pact) { instance_double(PactBroker::Models::Pact, json_content: previous_json_content)}
41
+ let(:previous_pact) { instance_double(PactBroker::Domain::Pact, json_content: previous_json_content)}
42
42
  let(:previous_json_content) { {'some' => 'json'}.to_json }
43
43
 
44
44
  context "when the json_content is the same" do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'pact_broker/services/pacticipant_service'
3
- require 'pact_broker/models/tag'
4
- require 'pact_broker/models/pact'
3
+ require 'pact_broker/domain/tag'
4
+ require 'pact_broker/domain/pact'
5
5
 
6
6
 
7
7
  module PactBroker
@@ -98,17 +98,17 @@ module PactBroker
98
98
 
99
99
  describe ".find_relationships" do
100
100
 
101
- let(:consumer) { instance_double("PactBroker::Models::Pacticipant")}
102
- let(:provider) { instance_double("PactBroker::Models::Pacticipant")}
103
- let(:pact) { instance_double("PactBroker::Models::Pact", consumer: consumer, provider: provider)}
101
+ let(:consumer) { instance_double("PactBroker::Domain::Pacticipant")}
102
+ let(:provider) { instance_double("PactBroker::Domain::Pacticipant")}
103
+ let(:pact) { instance_double("PactBroker::Domain::Pact", consumer: consumer, provider: provider)}
104
104
  let(:pacts) { [pact]}
105
105
 
106
106
  before do
107
- allow_any_instance_of(PactBroker::Repositories::PactRepository).to receive(:find_latest_pacts).and_return(pacts)
107
+ allow_any_instance_of(PactBroker::Pacts::Repository).to receive(:find_latest_pacts).and_return(pacts)
108
108
  end
109
109
 
110
110
  it "returns a list of relationships" do
111
- expect(subject.find_relationships).to eq([PactBroker::Models::Relationship.create(consumer, provider)])
111
+ expect(subject.find_relationships).to eq([PactBroker::Domain::Relationship.create(consumer, provider)])
112
112
  end
113
113
 
114
114
  end
@@ -131,19 +131,19 @@ module PactBroker
131
131
 
132
132
  it "deletes the pacticipant" do
133
133
  expect{ delete_pacticipant }.to change{
134
- PactBroker::Models::Pacticipant.all.count
134
+ PactBroker::Domain::Pacticipant.all.count
135
135
  }.by(-1)
136
136
  end
137
137
 
138
138
  it "deletes the child versions" do
139
139
  expect{ delete_pacticipant }.to change{
140
- PactBroker::Models::Version.where(number: "1.2.3").count
140
+ PactBroker::Domain::Version.where(number: "1.2.3").count
141
141
  }.by(-1)
142
142
  end
143
143
 
144
144
  it "deletes the child tags" do
145
145
  expect{ delete_pacticipant }.to change{
146
- PactBroker::Models::Tag.where(name: "prod").count
146
+ PactBroker::Domain::Tag.where(name: "prod").count
147
147
  }.by(-1)
148
148
  end
149
149
 
@@ -155,7 +155,7 @@ module PactBroker
155
155
 
156
156
  it "deletes the child pacts" do
157
157
  expect{ delete_pacticipant }.to change{
158
- PactBroker::Repositories::Pact.count
158
+ PactBroker::Pacts::DatabaseModel.count
159
159
  }.by(-2)
160
160
  end
161
161
  end
@@ -8,11 +8,11 @@ module PactBroker
8
8
 
9
9
  describe ".execute_webhooks" do
10
10
 
11
- let(:pact) { instance_double(PactBroker::Models::Pact, consumer: consumer, provider: provider, consumer_version: consumer_version)}
12
- let(:consumer_version) { PactBroker::Models::Version.new(number: '1.2.3') }
13
- let(:consumer) { PactBroker::Models::Pacticipant.new(name: 'Consumer') }
14
- let(:provider) { PactBroker::Models::Pacticipant.new(name: 'Provider') }
15
- let(:webhooks) { [instance_double(PactBroker::Models::Webhook)]}
11
+ let(:pact) { instance_double(PactBroker::Domain::Pact, consumer: consumer, provider: provider, consumer_version: consumer_version)}
12
+ let(:consumer_version) { PactBroker::Domain::Version.new(number: '1.2.3') }
13
+ let(:consumer) { PactBroker::Domain::Pacticipant.new(name: 'Consumer') }
14
+ let(:provider) { PactBroker::Domain::Pacticipant.new(name: 'Provider') }
15
+ let(:webhooks) { [instance_double(PactBroker::Domain::Webhook)]}
16
16
 
17
17
  before do
18
18
  allow_any_instance_of(PactBroker::Repositories::WebhookRepository).to receive(:find_by_consumer_and_provider).and_return(webhooks)
@@ -15,9 +15,9 @@ module PactBroker
15
15
  describe "/" do
16
16
  describe "GET" do
17
17
 
18
- let(:consumer) { instance_double("PactBroker::Models::Pacticipant", name: 'consumer_name')}
19
- let(:provider) { instance_double("PactBroker::Models::Pacticipant", name: 'provider_name')}
20
- let(:relationship) { PactBroker::Models::Relationship.new(consumer, provider)}
18
+ let(:consumer) { instance_double("PactBroker::Domain::Pacticipant", name: 'consumer_name')}
19
+ let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'provider_name')}
20
+ let(:relationship) { PactBroker::Domain::Relationship.new(consumer, provider)}
21
21
  let(:relationships) { [relationship] }
22
22
 
23
23
  before do
@@ -3,12 +3,12 @@ require 'pact_broker/ui/view_models/relationship'
3
3
 
4
4
  module PactBroker
5
5
  module UI
6
- module ViewModels
6
+ module ViewDomain
7
7
  describe Relationship do
8
8
 
9
- let(:consumer) { instance_double("PactBroker::Models::Pacticipant", name: 'Consumer Name')}
10
- let(:provider) { instance_double("PactBroker::Models::Pacticipant", name: 'Provider Name')}
11
- let(:relationship) { PactBroker::Models::Relationship.new(consumer, provider)}
9
+ let(:consumer) { instance_double("PactBroker::Domain::Pacticipant", name: 'Consumer Name')}
10
+ let(:provider) { instance_double("PactBroker::Domain::Pacticipant", name: 'Provider Name')}
11
+ let(:relationship) { PactBroker::Domain::Relationship.new(consumer, provider)}
12
12
 
13
13
  subject { Relationship.new(relationship) }
14
14
 
@@ -20,10 +20,10 @@ module PactBroker
20
20
 
21
21
  describe "<=>" do
22
22
 
23
- let(:relationship_model_4) { double("PactBroker::Models::Relationship", consumer_name: "A", provider_name: "X") }
24
- let(:relationship_model_2) { double("PactBroker::Models::Relationship", consumer_name: "a", provider_name: "y") }
25
- let(:relationship_model_3) { double("PactBroker::Models::Relationship", consumer_name: "A", provider_name: "Z") }
26
- let(:relationship_model_1) { double("PactBroker::Models::Relationship", consumer_name: "C", provider_name: "A") }
23
+ let(:relationship_model_4) { double("PactBroker::Domain::Relationship", consumer_name: "A", provider_name: "X") }
24
+ let(:relationship_model_2) { double("PactBroker::Domain::Relationship", consumer_name: "a", provider_name: "y") }
25
+ let(:relationship_model_3) { double("PactBroker::Domain::Relationship", consumer_name: "A", provider_name: "Z") }
26
+ let(:relationship_model_1) { double("PactBroker::Domain::Relationship", consumer_name: "C", provider_name: "A") }
27
27
 
28
28
  let(:relationship_models) { [relationship_model_1, relationship_model_3, relationship_model_4, relationship_model_2] }
29
29
  let(:ordered_view_models) { [relationship_model_4, relationship_model_2, relationship_model_3, relationship_model_1] }
@@ -3,13 +3,13 @@ require 'pact_broker/ui/view_models/relationships'
3
3
 
4
4
  module PactBroker
5
5
  module UI
6
- module ViewModels
6
+ module ViewDomain
7
7
  describe Relationships do
8
8
 
9
- let(:relationship_model_4) { double("PactBroker::Models::Relationship", consumer_name: "A", provider_name: "X") }
10
- let(:relationship_model_2) { double("PactBroker::Models::Relationship", consumer_name: "a", provider_name: "y") }
11
- let(:relationship_model_3) { double("PactBroker::Models::Relationship", consumer_name: "A", provider_name: "Z") }
12
- let(:relationship_model_1) { double("PactBroker::Models::Relationship", consumer_name: "C", provider_name: "A") }
9
+ let(:relationship_model_4) { double("PactBroker::Domain::Relationship", consumer_name: "A", provider_name: "X") }
10
+ let(:relationship_model_2) { double("PactBroker::Domain::Relationship", consumer_name: "a", provider_name: "y") }
11
+ let(:relationship_model_3) { double("PactBroker::Domain::Relationship", consumer_name: "A", provider_name: "Z") }
12
+ let(:relationship_model_1) { double("PactBroker::Domain::Relationship", consumer_name: "C", provider_name: "A") }
13
13
 
14
14
  subject { Relationships.new([relationship_model_1, relationship_model_3, relationship_model_4, relationship_model_2]) }
15
15
 
@@ -27,6 +27,29 @@ module PactBroker
27
27
  end
28
28
  end
29
29
 
30
+ describe "size_label" do
31
+ context "when there is 1 relationship" do
32
+ subject { Relationships.new([relationship_model_1]) }
33
+
34
+ it "returns '1 pact'" do
35
+ expect(subject.size_label).to eq "1 pact"
36
+ end
37
+ end
38
+ context "when there are 0 relationships" do
39
+ subject { Relationships.new([]) }
40
+
41
+ it "returns '0 pacts'" do
42
+ expect(subject.size_label).to eq "0 pacts"
43
+ end
44
+ end
45
+ context "when there is more than 1 relationship" do
46
+ subject { Relationships.new([relationship_model_1, relationship_model_1]) }
47
+
48
+ it "returns 'x pacts'" do
49
+ expect(subject.size_label).to eq "2 pacts"
50
+ end
51
+ end
52
+ end
30
53
  end
31
54
  end
32
55
  end
@@ -60,26 +60,26 @@ class ProviderStateBuilder
60
60
  self
61
61
  end
62
62
 
63
- def create_pact_with_hierarchy consumer_name, consumer_version, provider_name
64
- provider = PactBroker::Models::Pacticipant.create(:name => provider_name)
65
- consumer = PactBroker::Models::Pacticipant.create(:name => consumer_name)
66
- version = PactBroker::Models::Version.create(:number => consumer_version, :pacticipant => consumer)
67
- PactBroker::Repositories::Pact.create(:consumer_version => version, :provider => provider, :json_content => default_json_content).to_model
63
+ def create_pact_with_hierarchy consumer_name, consumer_version, provider_name, json_content = default_json_content
64
+ provider = PactBroker::Domain::Pacticipant.create(:name => provider_name)
65
+ consumer = PactBroker::Domain::Pacticipant.create(:name => consumer_name)
66
+ version = PactBroker::Domain::Version.create(:number => consumer_version, :pacticipant => consumer)
67
+ PactBroker::Pacts::Repository.new.create(version_id: version.id, provider_id: provider.id, json_content: json_content)
68
68
  end
69
69
 
70
70
  def create_version_with_hierarchy pacticipant_name, pacticipant_version
71
- pacticipant = PactBroker::Models::Pacticipant.create(:name => pacticipant_name)
72
- version = PactBroker::Models::Version.create(:number => pacticipant_version, :pacticipant => pacticipant)
73
- PactBroker::Models::Version.find(id: version.id) # Get version with populated order
71
+ pacticipant = PactBroker::Domain::Pacticipant.create(:name => pacticipant_name)
72
+ version = PactBroker::Domain::Version.create(:number => pacticipant_version, :pacticipant => pacticipant)
73
+ PactBroker::Domain::Version.find(id: version.id) # Get version with populated order
74
74
  end
75
75
 
76
76
  def create_tag_with_hierarchy pacticipant_name, pacticipant_version, tag_name
77
77
  version = create_version_with_hierarchy pacticipant_name, pacticipant_version
78
- PactBroker::Models::Tag.create(name: tag_name, version: version)
78
+ PactBroker::Domain::Tag.create(name: tag_name, version: version)
79
79
  end
80
80
 
81
81
  def create_pacticipant pacticipant_name
82
- @pacticipant = PactBroker::Models::Pacticipant.create(:name => pacticipant_name)
82
+ @pacticipant = PactBroker::Domain::Pacticipant.create(:name => pacticipant_name)
83
83
  self
84
84
  end
85
85
 
@@ -96,33 +96,33 @@ class ProviderStateBuilder
96
96
  end
97
97
 
98
98
  def create_version version_number
99
- @version = PactBroker::Models::Version.create(:number => version_number, :pacticipant => @pacticipant)
99
+ @version = PactBroker::Domain::Version.create(:number => version_number, :pacticipant => @pacticipant)
100
100
  self
101
101
  end
102
102
 
103
103
  def create_consumer_version version_number
104
- @consumer_version = PactBroker::Models::Version.create(:number => version_number, :pacticipant => @consumer)
104
+ @consumer_version = PactBroker::Domain::Version.create(:number => version_number, :pacticipant => @consumer)
105
105
  self
106
106
  end
107
107
 
108
108
  def create_tag tag_name
109
- @tag = PactBroker::Models::Tag.create(name: tag_name, version: @version)
109
+ @tag = PactBroker::Domain::Tag.create(name: tag_name, version: @version)
110
110
  self
111
111
  end
112
112
 
113
113
  def create_consumer_version_tag tag_name
114
- @tag = PactBroker::Models::Tag.create(name: tag_name, version: @consumer_version)
114
+ @tag = PactBroker::Domain::Tag.create(name: tag_name, version: @consumer_version)
115
115
  self
116
116
  end
117
117
 
118
118
  def create_pact json_content = default_json_content
119
- @pact = PactBroker::Repositories::Pact.create(consumer_version: @consumer_version, provider: @provider, json_content: json_content)
119
+ @pact = PactBroker::Pacts::Repository.new.create(version_id: @consumer_version.id, provider_id: @provider.id, json_content: json_content)
120
120
  self
121
121
  end
122
122
 
123
123
  def create_webhook
124
- request = PactBroker::Models::WebhookRequest.new(method: 'POST', url: 'http://example.org', headers: {'Content-Type' => 'application/json'})
125
- @webhook = WebhookRepository.new.create PactBroker::Services::WebhookService.next_uuid, PactBroker::Models::Webhook.new(request: request), @consumer, @provider
124
+ request = PactBroker::Domain::WebhookRequest.new(method: 'POST', url: 'http://example.org', headers: {'Content-Type' => 'application/json'})
125
+ @webhook = WebhookRepository.new.create PactBroker::Services::WebhookService.next_uuid, PactBroker::Domain::Webhook.new(request: request), @consumer, @provider
126
126
  self
127
127
  end
128
128
 
data/tasks/db.rake CHANGED
@@ -37,7 +37,7 @@ namespace :db do
37
37
  end
38
38
 
39
39
  desc 'Prepare the test database for running specs - RACK_ENV will be hardcoded to "test"'
40
- task 'prepare:test' => ['db:set_test_env','db:prepare_dir','db:migrate']
40
+ task 'prepare:test' => ['db:set_test_env','db:prepare_dir','db:delete','db:migrate']
41
41
 
42
42
  desc 'Reset the database (rollback then migrate) - uses RACK_ENV, defaulting to "development"'
43
43
  task :reset => ['db:rollback', 'db:migrate']
@@ -50,7 +50,6 @@ namespace :db do
50
50
  # Private: Ensure the dev/test database directory exists
51
51
  task 'prepare_dir' => 'db:env' do
52
52
  PactBroker::Database.ensure_database_dir_exists
53
- PactBroker::Database.delete_database_file
54
53
  end
55
54
 
56
55
  # Private
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: 1.3.1
4
+ version: 1.3.2.rc1
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: 2014-10-23 00:00:00.000000000 Z
13
+ date: 2014-12-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -347,9 +347,19 @@ files:
347
347
  - db/migrations/12_create_webhooks_table.rb
348
348
  - db/migrations/13_add_columns_to_webhooks.rb
349
349
  - db/migrations/14_add_timestamps_to_pact_views.rb
350
+ - db/migrations/15_add_value_to_tag.rb.wip
351
+ - db/migrations/15_create_pact_version_content.rb
352
+ - db/migrations/16_add_pact_content_foreign_key_to_pacts.rb
353
+ - db/migrations/17_migrate_json_content_to_pact_version_content_table.rb
354
+ - db/migrations/18_drop_json_content_column_from_pacts.rb
355
+ - db/migrations/19_make_pact_version_content_sha_not_nullable.rb
356
+ - db/migrations/20_add_pact_version_content_sha_to_all_pacts_view.rb
357
+ - db/migrations/21_recreate_latest_pacts_view.rb
358
+ - db/migrations/migration_helper.rb
350
359
  - db/pact_broker_database.sqlite3
351
360
  - example/Gemfile
352
361
  - example/config.ru
362
+ - example/pact_broker_database.sqlite3
353
363
  - lib/db.rb
354
364
  - lib/pact_broker.rb
355
365
  - lib/pact_broker/api.rb
@@ -404,40 +414,44 @@ files:
404
414
  - lib/pact_broker/configuration.rb
405
415
  - lib/pact_broker/constants.rb
406
416
  - lib/pact_broker/db.rb
417
+ - lib/pact_broker/db/validate_encoding.rb
407
418
  - lib/pact_broker/doc/controllers/app.rb
408
419
  - lib/pact_broker/doc/views/latest-pacts.markdown
409
420
  - lib/pact_broker/doc/views/layouts/main.haml
410
421
  - lib/pact_broker/doc/views/pacticipants.markdown
411
422
  - lib/pact_broker/doc/views/self.markdown
412
423
  - lib/pact_broker/doc/views/webhooks.markdown
424
+ - lib/pact_broker/domain.rb
425
+ - lib/pact_broker/domain/group.rb
426
+ - lib/pact_broker/domain/order_versions.rb
427
+ - lib/pact_broker/domain/pact.rb
428
+ - lib/pact_broker/domain/pacticipant.rb
429
+ - lib/pact_broker/domain/relationship.rb
430
+ - lib/pact_broker/domain/tag.rb
431
+ - lib/pact_broker/domain/version.rb
432
+ - lib/pact_broker/domain/webhook.rb
433
+ - lib/pact_broker/domain/webhook_execution_result.rb
434
+ - lib/pact_broker/domain/webhook_request.rb
435
+ - lib/pact_broker/domain/webhook_request_header.rb
413
436
  - lib/pact_broker/functions/find_potential_duplicate_pacticipant_names.rb
414
437
  - lib/pact_broker/functions/groupify.rb
415
- - lib/pact_broker/jobs/after_pact_save.rb
416
438
  - lib/pact_broker/json.rb
417
439
  - lib/pact_broker/locale/en.yml
418
440
  - lib/pact_broker/logging.rb
419
441
  - lib/pact_broker/messages.rb
420
- - lib/pact_broker/models.rb
421
- - lib/pact_broker/models/group.rb
422
- - lib/pact_broker/models/order_versions.rb
423
- - lib/pact_broker/models/pact.rb
424
- - lib/pact_broker/models/pacticipant.rb
425
- - lib/pact_broker/models/relationship.rb
426
- - lib/pact_broker/models/tag.rb
427
- - lib/pact_broker/models/version.rb
428
- - lib/pact_broker/models/webhook.rb
429
- - lib/pact_broker/models/webhook_execution_result.rb
430
- - lib/pact_broker/models/webhook_request.rb
431
- - lib/pact_broker/models/webhook_request_header.rb
442
+ - lib/pact_broker/pacts/all_pacts.rb
443
+ - lib/pact_broker/pacts/database_model.rb
444
+ - lib/pact_broker/pacts/latest_pacts.rb
432
445
  - lib/pact_broker/pacts/pact_params.rb
446
+ - lib/pact_broker/pacts/pact_version_content.rb
447
+ - lib/pact_broker/pacts/repository.rb
433
448
  - lib/pact_broker/project_root.rb
434
449
  - lib/pact_broker/repositories.rb
435
- - lib/pact_broker/repositories/pact.rb
436
450
  - lib/pact_broker/repositories/pact_content.rb
437
- - lib/pact_broker/repositories/pact_repository.rb
438
451
  - lib/pact_broker/repositories/pacticipant_repository.rb
439
452
  - lib/pact_broker/repositories/tag_repository.rb
440
453
  - lib/pact_broker/repositories/version_repository.rb
454
+ - lib/pact_broker/repositories/webhook.rb
441
455
  - lib/pact_broker/repositories/webhook_repository.rb
442
456
  - lib/pact_broker/services.rb
443
457
  - lib/pact_broker/services/group_service.rb
@@ -492,13 +506,17 @@ files:
492
506
  - public/stylesheets/pact.css
493
507
  - public/stylesheets/relationships.css
494
508
  - script/update-hal-browser
509
+ - spec/features/create_webhook_spec.rb
510
+ - spec/features/delete_pact_spec.rb
511
+ - spec/features/publish_pact_spec.rb
512
+ - spec/features/update_pacticipant_spec.rb
495
513
  - spec/fixtures/consumer-provider.json
496
514
  - spec/fixtures/renderer_pact.json
515
+ - spec/fixtures/update_pacticipant.json
516
+ - spec/fixtures/updated_pacticipant.json
497
517
  - spec/fixtures/webhook_valid.json
498
518
  - spec/integration/app_spec.rb
499
519
  - spec/integration/endpoints/group.rb
500
- - spec/integration/endpoints/pact_put_spec.rb
501
- - spec/integration/endpoints/pact_webhooks_spec.rb
502
520
  - spec/lib/pact_broker/api/contracts/put_pact_params_contract_spec.rb
503
521
  - spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb
504
522
  - spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
@@ -524,17 +542,18 @@ files:
524
542
  - spec/lib/pact_broker/api/resources/webhook_spec.rb
525
543
  - spec/lib/pact_broker/api/resources/webhooks_spec.rb
526
544
  - spec/lib/pact_broker/configuration_spec.rb
545
+ - spec/lib/pact_broker/db/validate_encoding_spec.rb
527
546
  - spec/lib/pact_broker/doc/controllers/app_spec.rb
547
+ - spec/lib/pact_broker/domain/group_spec.rb
548
+ - spec/lib/pact_broker/domain/order_versions_spec.rb
549
+ - spec/lib/pact_broker/domain/pacticipant_spec.rb
550
+ - spec/lib/pact_broker/domain/webhook_request_spec.rb
551
+ - spec/lib/pact_broker/domain/webhook_spec.rb
528
552
  - spec/lib/pact_broker/functions/find_potential_duplicate_pacticipant_names_spec.rb
529
553
  - spec/lib/pact_broker/functions/groupify_spec.rb
530
554
  - spec/lib/pact_broker/messages_spec.rb
531
- - spec/lib/pact_broker/models/group_spec.rb
532
- - spec/lib/pact_broker/models/order_versions_spec.rb
533
- - spec/lib/pact_broker/models/pacticipant_spec.rb
534
- - spec/lib/pact_broker/models/webhook_request_spec.rb
535
- - spec/lib/pact_broker/models/webhook_spec.rb
536
555
  - spec/lib/pact_broker/pacts/pact_params_spec.rb
537
- - spec/lib/pact_broker/repositories/pact_repository_spec.rb
556
+ - spec/lib/pact_broker/pacts/repository_spec.rb
538
557
  - spec/lib/pact_broker/repositories/pacticipant_repository_spec.rb
539
558
  - spec/lib/pact_broker/repositories/tag_repository_spec.rb
540
559
  - spec/lib/pact_broker/repositories/version_repository_spec.rb
@@ -611,9 +630,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
611
630
  version: '0'
612
631
  required_rubygems_version: !ruby/object:Gem::Requirement
613
632
  requirements:
614
- - - ">="
633
+ - - ">"
615
634
  - !ruby/object:Gem::Version
616
- version: '0'
635
+ version: 1.3.1
617
636
  requirements: []
618
637
  rubyforge_project:
619
638
  rubygems_version: 2.2.2
@@ -621,13 +640,17 @@ signing_key:
621
640
  specification_version: 4
622
641
  summary: See description
623
642
  test_files:
643
+ - spec/features/create_webhook_spec.rb
644
+ - spec/features/delete_pact_spec.rb
645
+ - spec/features/publish_pact_spec.rb
646
+ - spec/features/update_pacticipant_spec.rb
624
647
  - spec/fixtures/consumer-provider.json
625
648
  - spec/fixtures/renderer_pact.json
649
+ - spec/fixtures/update_pacticipant.json
650
+ - spec/fixtures/updated_pacticipant.json
626
651
  - spec/fixtures/webhook_valid.json
627
652
  - spec/integration/app_spec.rb
628
653
  - spec/integration/endpoints/group.rb
629
- - spec/integration/endpoints/pact_put_spec.rb
630
- - spec/integration/endpoints/pact_webhooks_spec.rb
631
654
  - spec/lib/pact_broker/api/contracts/put_pact_params_contract_spec.rb
632
655
  - spec/lib/pact_broker/api/contracts/webhook_contract_spec.rb
633
656
  - spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
@@ -653,17 +676,18 @@ test_files:
653
676
  - spec/lib/pact_broker/api/resources/webhook_spec.rb
654
677
  - spec/lib/pact_broker/api/resources/webhooks_spec.rb
655
678
  - spec/lib/pact_broker/configuration_spec.rb
679
+ - spec/lib/pact_broker/db/validate_encoding_spec.rb
656
680
  - spec/lib/pact_broker/doc/controllers/app_spec.rb
681
+ - spec/lib/pact_broker/domain/group_spec.rb
682
+ - spec/lib/pact_broker/domain/order_versions_spec.rb
683
+ - spec/lib/pact_broker/domain/pacticipant_spec.rb
684
+ - spec/lib/pact_broker/domain/webhook_request_spec.rb
685
+ - spec/lib/pact_broker/domain/webhook_spec.rb
657
686
  - spec/lib/pact_broker/functions/find_potential_duplicate_pacticipant_names_spec.rb
658
687
  - spec/lib/pact_broker/functions/groupify_spec.rb
659
688
  - spec/lib/pact_broker/messages_spec.rb
660
- - spec/lib/pact_broker/models/group_spec.rb
661
- - spec/lib/pact_broker/models/order_versions_spec.rb
662
- - spec/lib/pact_broker/models/pacticipant_spec.rb
663
- - spec/lib/pact_broker/models/webhook_request_spec.rb
664
- - spec/lib/pact_broker/models/webhook_spec.rb
665
689
  - spec/lib/pact_broker/pacts/pact_params_spec.rb
666
- - spec/lib/pact_broker/repositories/pact_repository_spec.rb
690
+ - spec/lib/pact_broker/pacts/repository_spec.rb
667
691
  - spec/lib/pact_broker/repositories/pacticipant_repository_spec.rb
668
692
  - spec/lib/pact_broker/repositories/tag_repository_spec.rb
669
693
  - spec/lib/pact_broker/repositories/version_repository_spec.rb