pact_broker 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 294af60b2b620028e089b70e4b2cb6b679f80258
4
- data.tar.gz: 6fbf2858e2c429ecbe0e77a1380b33da6cfd590b
3
+ metadata.gz: 082fae49739e644a0b575b9242ac248f63606e04
4
+ data.tar.gz: 19c28520e5b3076c27d7e5f806f8aafae3ba0c1d
5
5
  SHA512:
6
- metadata.gz: 632f9bbd33da917be4ffa13af123b88e62f248f01b66b9dfae3e61758a37980b6727e5b643583edd393aa77c58dcfbc02e92e14a3b898660a9ec3a92968ac7cb
7
- data.tar.gz: 04078604d77fd13715d2b7c73f67123129a56c1028319e7d7f248ac9ef6e42259c58efeac437de71b7c745702424b4121416b745707cb5ca76cfd0295b8f11b9
6
+ metadata.gz: be084a3e0fb139081fdb05acd03317cd0a7b7b9617196a0a8f2c1accd2b5df18d94cc4532f4e4ac03c6613c3acaf60f8cebc5f2fc1806674f1d0c7c33049b25e
7
+ data.tar.gz: 0bfcd1da43d8f1ebb81fa5b5661d5632a0c82be9383b1dfc0217c338386cf4b337be32c488a41a13853e600ae647475ae0f92ac971d4f6ec5ba946deaf13b0ac
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
2
2
 
3
3
  $ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
4
4
 
5
+ #### 1.14.0 (2017-01-30)
6
+ * 83ac7a5 - Adds ability to delete tags (Ivan Vojinovic, Fri Jan 27 15:19:51 2017 -0500)
7
+
5
8
  #### 1.13.0 (2017-01-18)
6
9
  * b9b67b3 - Adds the spec for pact versions endpoint, and corrects the file name for the provider pacts spec (Ivan Vojinovic, Tue Jan 17 23:43:03 2017 -0500)
7
10
  * ace427e - Adds the spec for pact versions endpoint, and corrects the file name for the provider pacts spec (Ivan Vojinovic, Tue Jan 17 23:36:33 2017 -0500)
@@ -15,7 +15,7 @@ module PactBroker
15
15
  end
16
16
 
17
17
  def allowed_methods
18
- ["GET","PUT"]
18
+ ["GET","PUT","DELETE"]
19
19
  end
20
20
 
21
21
  def from_json
@@ -39,6 +39,11 @@ module PactBroker
39
39
  @tag ||= tag_service.find identifier_from_path
40
40
  end
41
41
 
42
+ def delete_resource
43
+ tag_service.delete identifier_from_path
44
+ true
45
+ end
46
+
42
47
  end
43
48
  end
44
49
 
@@ -19,6 +19,12 @@ module PactBroker
19
19
  tag_repository.find args
20
20
  end
21
21
 
22
+ def delete args
23
+ version = version_repository.find_by_pacticipant_name_and_number args.fetch(:pacticipant_name), args.fetch(:pacticipant_version_number)
24
+ connection = PactBroker::Domain::Tag.new.db
25
+ connection.run("delete from tags where name = '#{args.fetch(:tag_name)}' and version_id = '#{version.id}'")
26
+ end
27
+
22
28
  end
23
29
  end
24
30
 
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '1.13.0'
2
+ VERSION = '1.14.0'
3
3
  end
@@ -19,6 +19,60 @@ module PactBroker
19
19
  }
20
20
  }
21
21
 
22
+ describe "DELETE" do
23
+ before do
24
+ allow(Services::TagService).to receive(:find).and_return(tag)
25
+ allow(Services::TagService).to receive(:delete)
26
+ end
27
+
28
+ subject { delete("/pacticipants/Condor/versions/1.3.0/tags/prod" ) }
29
+
30
+ context "when the tag exists" do
31
+ it "deletes the tag by name" do
32
+ expect(Services::TagService).to receive(:delete) .with(tag_attributes)
33
+ subject
34
+ end
35
+
36
+ it "returns a 204 OK" do
37
+ subject
38
+ expect(last_response.status).to eq 204
39
+ end
40
+ end
41
+
42
+ context "when the tag doesn't exist" do
43
+
44
+ let(:tag) { nil }
45
+
46
+ it "returns a 404 Not Found" do
47
+ subject
48
+ expect(last_response.status).to eq 404
49
+ end
50
+ end
51
+
52
+ context "when an error occurs" do
53
+ before do
54
+ allow(Services::TagService).to receive(:delete).and_raise("An error")
55
+ end
56
+
57
+ let(:response_body) { JSON.parse(last_response.body, symbolize_names: true) }
58
+
59
+ it "returns a 500 Internal Server Error" do
60
+ subject
61
+ expect(last_response.status).to eq 500
62
+ end
63
+
64
+ it "returns an error message" do
65
+ subject
66
+ expect(response_body[:message]).to eq "An error"
67
+ end
68
+
69
+ it "returns the backtrace" do
70
+ subject
71
+ expect(response_body[:backtrace]).to be_instance_of(Array)
72
+ end
73
+ end
74
+ end
75
+
22
76
  describe "GET" do
23
77
  before do
24
78
  allow(Services::TagService).to receive(:find).and_return(tag)
@@ -5,14 +5,14 @@ module PactBroker
5
5
  module Services
6
6
  describe TagService do
7
7
 
8
- describe ".create" do
8
+ let(:pacticipant_name) { "test_pacticipant" }
9
+ let(:version_number) { "1.2.3" }
10
+ let(:tag_name) { "prod" }
9
11
 
10
- let(:pacticipant_name) { "test_pacticipant" }
11
- let(:version_number) { "1.2.3" }
12
- let(:tag_name) { "prod" }
12
+ let(:options) { {pacticipant_name: pacticipant_name, pacticipant_version_number: version_number, tag_name: tag_name}}
13
+ let(:provider_state_builder) { ProviderStateBuilder.new }
13
14
 
14
- let(:options) { {pacticipant_name: pacticipant_name, pacticipant_version_number: version_number, tag_name: tag_name}}
15
- let(:provider_state_builder) { ProviderStateBuilder.new }
15
+ describe ".create" do
16
16
 
17
17
  subject { TagService.create(options) }
18
18
 
@@ -26,6 +26,26 @@ module PactBroker
26
26
 
27
27
  end
28
28
 
29
+ describe "delete" do
30
+
31
+ let(:second_pacticipant_name) { "second_test_pacticipant" }
32
+ let(:second_version_number) { "4.5.6" }
33
+ let(:second_options_same_tag_name) { {pacticipant_name: second_pacticipant_name, pacticipant_version_number: second_version_number, tag_name: tag_name}}
34
+
35
+ before do
36
+ TagService.create(options)
37
+ TagService.create(second_options_same_tag_name)
38
+ end
39
+
40
+ let(:delete_tag_for_particpant_and_version) { subject.delete second_options_same_tag_name}
41
+
42
+ it "deletes the tag for the particpiant and the version" do
43
+ expect{ delete_tag_for_particpant_and_version }.to change{
44
+ PactBroker::Domain::Tag.all.count
45
+ }.by(-1)
46
+ end
47
+ end
48
+
29
49
  end
30
50
  end
31
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-01-18 00:00:00.000000000 Z
13
+ date: 2017-01-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty