pact_broker 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/db/migrations/23_create_pact_versions_table.rb +1 -5
- data/lib/pact_broker/api.rb +6 -0
- data/lib/pact_broker/api/resources/badge.rb +60 -0
- data/lib/pact_broker/badges/service.rb +107 -0
- data/lib/pact_broker/configuration.rb +3 -2
- data/lib/pact_broker/doc/views/publish-verification-results.markdown +4 -4
- data/lib/pact_broker/domain/relationship.rb +7 -1
- data/lib/pact_broker/domain/verification.rb +12 -0
- data/lib/pact_broker/locale/en.yml +2 -0
- data/lib/pact_broker/logging.rb +4 -2
- data/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb +11 -5
- data/lib/pact_broker/pacts/service.rb +1 -1
- data/lib/pact_broker/services.rb +5 -0
- data/lib/pact_broker/ui/view_models/relationship.rb +12 -14
- data/lib/pact_broker/verifications/repository.rb +8 -4
- data/lib/pact_broker/verifications/service.rb +2 -2
- data/lib/pact_broker/verifications/verification_status.rb +47 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/rack/pact_broker/convert_file_extension_to_accept_header.rb +1 -1
- data/public/images/pact-changed-orange.svg +1 -0
- data/public/images/pact-failed-red.svg +1 -0
- data/public/images/pact-unknown-lightgrey.svg +1 -0
- data/public/images/pact-verified-brightgreen.svg +1 -0
- data/public/images/pact_not_found-unknown-lightgrey.svg +1 -0
- data/spec/features/get_latest_pact_badge_spec.rb +53 -0
- data/spec/features/get_latest_tagged_pact_badge_spec.rb +38 -0
- data/spec/features/get_latest_untagged_pact_badge_spec.rb +38 -0
- data/spec/features/publish_verification_spec.rb +8 -1
- data/spec/lib/pact_broker/api/resources/badge_spec.rb +104 -0
- data/spec/lib/pact_broker/badges/service_spec.rb +244 -0
- data/spec/lib/pact_broker/messages_spec.rb +2 -0
- data/spec/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names_spec.rb +44 -62
- data/spec/lib/pact_broker/pacts/service_spec.rb +0 -3
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +5 -7
- data/spec/lib/pact_broker/verifications/repository_spec.rb +102 -28
- data/spec/lib/pact_broker/verifications/verification_status_spec.rb +48 -0
- metadata +22 -2
| @@ -19,6 +19,8 @@ The name "Contracts" is very similar to the following existing consumers/provide | |
| 19 19 | 
             
            If you meant to specify one of the above names, please correct the pact configuration, and re-publish the pact.
         | 
| 20 20 | 
             
            If the pact is intended to be for a new consumer or provider, please manually create "Contracts" using the following command, and then re-publish the pact:
         | 
| 21 21 | 
             
            $ curl -v -XPOST -H "Content-Type: application/json" -d "{\\\"name\\\": \\\"Contracts\\\"}" http://example.org/pacticipants
         | 
| 22 | 
            +
            If the pact broker requires authentication, include the '-u' flag with the proper credentials:
         | 
| 23 | 
            +
            $ curl -v -XPOST -u <username>:<password> -H "Content-Type: application/json" -d "{\\\"name\\\": \\\"Contracts\\\"}" http://example.org/pacticipants
         | 
| 22 24 | 
             
            EOS
         | 
| 23 25 | 
             
                  }
         | 
| 24 26 | 
             
                  subject { Messages.potential_duplicate_pacticipant_message new_name, potential_duplicate_pacticipants, 'http://example.org' }
         | 
| @@ -7,76 +7,58 @@ module PactBroker | |
| 7 7 |  | 
| 8 8 | 
             
                describe FindPotentialDuplicatePacticipantNames do
         | 
| 9 9 |  | 
| 10 | 
            -
                  describe " | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                       | 
| 16 | 
            -
                       | 
| 17 | 
            -
             | 
| 18 | 
            -
                       | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
                      let(:existing_names) { ['Contract Service', 'Contacts', 'Something'] }
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                      it "returns the existing names that match" do
         | 
| 28 | 
            -
                        expect(subject).to eq ['Contract Service']
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
                    end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                    context "when a new name mostly includes an existing name" do
         | 
| 33 | 
            -
                      let(:new_name) { 'Contract Service' }
         | 
| 34 | 
            -
                      let(:existing_names) { ['Contracts', 'Contacts', 'Something'] }
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                      it "returns the existing names that match" do
         | 
| 37 | 
            -
                        expect(subject).to eq ['Contracts']
         | 
| 38 | 
            -
                      end
         | 
| 39 | 
            -
                    end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                    context 'when a new name is the same but a different case' do
         | 
| 42 | 
            -
                      let(:new_name) { 'Contract Service' }
         | 
| 43 | 
            -
                      let(:existing_names) { ['contracts', 'Contacts', 'Something'] }
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                      it "returns the existing names that match" do
         | 
| 46 | 
            -
                        expect(subject).to eq ['contracts']
         | 
| 47 | 
            -
                      end
         | 
| 48 | 
            -
                    end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                    context "when a new name is the same as an existing name but without spaces" do
         | 
| 51 | 
            -
                      let(:new_name) { 'ContractService' }
         | 
| 52 | 
            -
                      let(:existing_names) { ['Contracts Service', 'Contacts', 'Something'] }
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                      it "returns the existing names that match" do
         | 
| 55 | 
            -
                        expect(subject).to eq ['Contracts Service']
         | 
| 10 | 
            +
                  describe "split" do
         | 
| 11 | 
            +
                    TEST_CASES = [
         | 
| 12 | 
            +
                      ["a-foo-service", ["a", "foo", "service"]],
         | 
| 13 | 
            +
                      ["a_foo_service", ["a", "foo", "service"]],
         | 
| 14 | 
            +
                      ["FooAService", ["foo", "a", "service"]],
         | 
| 15 | 
            +
                      ["Foo A Service", ["foo", "a", "service"]],
         | 
| 16 | 
            +
                      ["S3 Bucket Service", ["s3", "bucket", "service"]],
         | 
| 17 | 
            +
                      ["S3BucketService", ["s3", "bucket", "service"]],
         | 
| 18 | 
            +
                      ["S3-Bucket-Service", ["s3", "bucket", "service"]],
         | 
| 19 | 
            +
                      ["S3_Bucket_Service", ["s3", "bucket", "service"]],
         | 
| 20 | 
            +
                    ]
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    TEST_CASES.each do | input, output |
         | 
| 23 | 
            +
                      it "splits #{input} into #{output.inspect}" do
         | 
| 24 | 
            +
                        expect(FindPotentialDuplicatePacticipantNames.split(input)).to eq output
         | 
| 56 25 | 
             
                      end
         | 
| 57 26 | 
             
                    end
         | 
| 27 | 
            +
                  end
         | 
| 58 28 |  | 
| 59 | 
            -
             | 
| 60 | 
            -
                      let(:new_name) { 'Contract Service' }
         | 
| 61 | 
            -
                      let(:existing_names) { ['ContractsService', 'Contacts', 'Something'] }
         | 
| 29 | 
            +
                  describe ".call" do
         | 
| 62 30 |  | 
| 63 | 
            -
             | 
| 64 | 
            -
                        expect(subject).to eq ['ContractsService']
         | 
| 65 | 
            -
                      end
         | 
| 66 | 
            -
                    end
         | 
| 31 | 
            +
                    subject { FindPotentialDuplicatePacticipantNames.call(new_name, existing_names) }
         | 
| 67 32 |  | 
| 68 | 
            -
                    context "when the new name is similar to an existing but with underscores or dashes instead of spaces" do
         | 
| 69 | 
            -
                      let(:new_name) { 'Contract_Service' }
         | 
| 70 | 
            -
                      let(:existing_names) { ['ContractsService', 'Contracts Service', 'contracts-service', 'Contacts', 'Something'] }
         | 
| 71 33 |  | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 34 | 
            +
                    TEST_CASES = [
         | 
| 35 | 
            +
                      ["accounts", ["accounts-receivable"], []],
         | 
| 36 | 
            +
                      ["Accounts", ["Accounts Receivable"], []],
         | 
| 37 | 
            +
                      ["The Accounts", ["Accounts"], []],
         | 
| 38 | 
            +
                      ["accounts", ["account-service", "account-api", "account-provider"], ["account-service", "account-api", "account-provider"]],
         | 
| 39 | 
            +
                      ["accounts-api", ["account-service", "account-provider"], ["account-service", "account-provider"]],
         | 
| 40 | 
            +
                      ['Contracts Service', ['Contracts Service', 'Contracts', 'Something'], []],
         | 
| 41 | 
            +
                      ['Contracts', ['Contract Service', 'Contacts', 'Something'], ['Contract Service']],
         | 
| 42 | 
            +
                      ['Contracts Service', ['Contract', 'Contacts', 'Something'], ['Contract']],
         | 
| 43 | 
            +
                      ['Contract Service', ['Contracts', 'Contacts', 'Something'], ['Contracts']],
         | 
| 44 | 
            +
                      ['Contract Service', ['contracts', 'Contacts', 'Something'], ['contracts']],
         | 
| 45 | 
            +
                      ['ContractService', ['Contracts Service', 'Contacts', 'Something'], ['Contracts Service']],
         | 
| 46 | 
            +
                      ['Contract Service', ['ContractsService', 'Contacts', 'Something'], ['ContractsService']],
         | 
| 47 | 
            +
                      ['Contract_Service', ['ContractsService', 'Contracts Service', 'contracts-service', 'Contacts', 'Something'], ['ContractsService', 'Contracts Service', 'contracts-service']]
         | 
| 48 | 
            +
                    ]
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    TEST_CASES.each do | the_new_name, the_existing_names, the_expected_duplicates |
         | 
| 51 | 
            +
                      context "when the new name is #{the_new_name} and the existing names are #{the_existing_names.inspect}" do
         | 
| 52 | 
            +
                        let(:new_name) { the_new_name }
         | 
| 53 | 
            +
                        let(:existing_names) { the_existing_names }
         | 
| 54 | 
            +
                        let(:expected_duplicates) { the_expected_duplicates}
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                        it "returns #{the_expected_duplicates.inspect} as the potential duplicates" do
         | 
| 57 | 
            +
                          expect(subject).to eq expected_duplicates
         | 
| 58 | 
            +
                        end
         | 
| 74 59 | 
             
                      end
         | 
| 75 60 | 
             
                    end
         | 
| 76 | 
            -
             | 
| 77 61 | 
             
                  end
         | 
| 78 | 
            -
             | 
| 79 62 | 
             
                end
         | 
| 80 | 
            -
             | 
| 81 63 | 
             
              end
         | 
| 82 | 
            -
            end
         | 
| 64 | 
            +
            end
         | 
| @@ -27,7 +27,6 @@ module PactBroker | |
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 29 | 
             
                  describe "#pact_has_changed_since_previous_version?" do
         | 
| 30 | 
            -
             | 
| 31 30 | 
             
                    let(:json_content) { { 'some' => 'json'}.to_json }
         | 
| 32 31 | 
             
                    let(:pact) { instance_double(PactBroker::Domain::Pact, json_content: json_content)}
         | 
| 33 32 |  | 
| @@ -61,9 +60,7 @@ module PactBroker | |
| 61 60 | 
             
                        expect(subject).to be_falsey
         | 
| 62 61 | 
             
                      end
         | 
| 63 62 | 
             
                    end
         | 
| 64 | 
            -
             | 
| 65 63 | 
             
                  end
         | 
| 66 | 
            -
             | 
| 67 64 | 
             
                end
         | 
| 68 65 | 
             
              end
         | 
| 69 66 | 
             
            end
         | 
| @@ -23,9 +23,7 @@ module PactBroker | |
| 23 23 | 
             
                    describe "verification_status" do
         | 
| 24 24 | 
             
                      let(:domain_relationship) do
         | 
| 25 25 | 
             
                        instance_double("PactBroker::Domain::Relationship",
         | 
| 26 | 
            -
                           | 
| 27 | 
            -
                          pact_changed_since_last_verification?: pact_changed,
         | 
| 28 | 
            -
                          latest_verification_successful?: success,
         | 
| 26 | 
            +
                          verification_status: verification_status,
         | 
| 29 27 | 
             
                          provider_name: "Foo",
         | 
| 30 28 | 
             
                          latest_verification_provider_version: "4.5.6")
         | 
| 31 29 | 
             
                      end
         | 
| @@ -36,28 +34,28 @@ module PactBroker | |
| 36 34 | 
             
                      subject { Relationship.new(domain_relationship) }
         | 
| 37 35 |  | 
| 38 36 | 
             
                      context "when the pact has never been verified" do
         | 
| 39 | 
            -
                        let(: | 
| 37 | 
            +
                        let(:verification_status) { :never }
         | 
| 40 38 | 
             
                        its(:verification_status) { is_expected.to eq "" }
         | 
| 41 39 | 
             
                        its(:warning?) { is_expected.to be false }
         | 
| 42 40 | 
             
                        its(:verification_tooltip) { is_expected.to eq nil }
         | 
| 43 41 | 
             
                      end
         | 
| 44 42 |  | 
| 45 43 | 
             
                      context "when the pact has changed since the last successful verification" do
         | 
| 46 | 
            -
                        let(: | 
| 44 | 
            +
                        let(:verification_status) { :stale }
         | 
| 47 45 | 
             
                        its(:verification_status) { is_expected.to eq "warning" }
         | 
| 48 46 | 
             
                        its(:warning?) { is_expected.to be true }
         | 
| 49 47 | 
             
                        its(:verification_tooltip) { is_expected.to eq "Pact has changed since last successful verification by Foo (v4.5.6)" }
         | 
| 50 48 | 
             
                      end
         | 
| 51 49 |  | 
| 52 50 | 
             
                      context "when the pact has not changed since the last successful verification" do
         | 
| 53 | 
            -
                        let(: | 
| 51 | 
            +
                        let(:verification_status) { :success }
         | 
| 54 52 | 
             
                        its(:verification_status) { is_expected.to eq "success" }
         | 
| 55 53 | 
             
                        its(:warning?) { is_expected.to be false }
         | 
| 56 54 | 
             
                        its(:verification_tooltip) { is_expected.to eq "Successfully verified by Foo (v4.5.6)" }
         | 
| 57 55 | 
             
                      end
         | 
| 58 56 |  | 
| 59 57 | 
             
                      context "when the pact verification failed" do
         | 
| 60 | 
            -
                        let(: | 
| 58 | 
            +
                        let(:verification_status) { :failed }
         | 
| 61 59 | 
             
                        its(:verification_status) { is_expected.to eq "danger" }
         | 
| 62 60 | 
             
                        its(:warning?) { is_expected.to be false }
         | 
| 63 61 | 
             
                        its(:verification_tooltip) { is_expected.to eq "Verification by Foo (v4.5.6) failed" }
         | 
| @@ -25,8 +25,10 @@ module PactBroker | |
| 25 25 | 
             
                        .and_return(:pact)
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 |  | 
| 28 | 
            +
                    subject { Repository.new.verification_count_for_pact(pact_1) }
         | 
| 29 | 
            +
             | 
| 28 30 | 
             
                    it "returns the number of verifications for the given pact" do
         | 
| 29 | 
            -
                      expect( | 
| 31 | 
            +
                      expect(subject).to eq 2
         | 
| 30 32 | 
             
                    end
         | 
| 31 33 | 
             
                  end
         | 
| 32 34 |  | 
| @@ -56,13 +58,13 @@ module PactBroker | |
| 56 58 | 
             
                      pact
         | 
| 57 59 | 
             
                    end
         | 
| 58 60 |  | 
| 59 | 
            -
                     | 
| 61 | 
            +
                    subject { Repository.new.find "Consumer1", "Provider1", pact.pact_version_sha, 2}
         | 
| 60 62 |  | 
| 61 63 | 
             
                    it "finds the latest verifications for the given consumer version" do
         | 
| 62 | 
            -
                      expect( | 
| 63 | 
            -
                      expect( | 
| 64 | 
            -
                      expect( | 
| 65 | 
            -
                      expect( | 
| 64 | 
            +
                      expect(subject.provider_version).to eq "3.7.4"
         | 
| 65 | 
            +
                      expect(subject.consumer_name).to eq "Consumer1"
         | 
| 66 | 
            +
                      expect(subject.provider_name).to eq "Provider1"
         | 
| 67 | 
            +
                      expect(subject.pact_version_sha).to eq pact.pact_version_sha
         | 
| 66 68 | 
             
                    end
         | 
| 67 69 | 
             
                  end
         | 
| 68 70 |  | 
| @@ -90,37 +92,109 @@ module PactBroker | |
| 90 92 | 
             
                        .create_verification(number: 1)
         | 
| 91 93 | 
             
                    end
         | 
| 92 94 |  | 
| 93 | 
            -
                     | 
| 95 | 
            +
                    subject { Repository.new.find_latest_verifications_for_consumer_version("Consumer1", "1.2.3")}
         | 
| 94 96 |  | 
| 95 97 | 
             
                    it "finds the latest verifications for the given consumer version" do
         | 
| 96 | 
            -
                      expect( | 
| 97 | 
            -
                      expect( | 
| 98 | 
            +
                      expect(subject.first.provider_version).to eq "7.8.9"
         | 
| 99 | 
            +
                      expect(subject.last.provider_version).to eq "6.5.4"
         | 
| 98 100 | 
             
                    end
         | 
| 99 101 | 
             
                  end
         | 
| 100 102 |  | 
| 101 103 | 
             
                  describe "#find_latest_verification_for" do
         | 
| 102 | 
            -
                     | 
| 103 | 
            -
                       | 
| 104 | 
            -
                        . | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 104 | 
            +
                    context "when no tag is specified" do
         | 
| 105 | 
            +
                      before do
         | 
| 106 | 
            +
                        TestDataBuilder.new
         | 
| 107 | 
            +
                          .create_provider("Provider1")
         | 
| 108 | 
            +
                          .create_consumer("Consumer1")
         | 
| 109 | 
            +
                          .create_consumer_version("1.2.3")
         | 
| 110 | 
            +
                          .create_pact
         | 
| 111 | 
            +
                          .create_verification(number: 1, provider_version: "2.3.4")
         | 
| 112 | 
            +
                          .create_verification(number: 2, provider_version: "7.8.9")
         | 
| 113 | 
            +
                          .create_consumer_version("1.0.0")
         | 
| 114 | 
            +
                          .create_pact
         | 
| 115 | 
            +
                          .create_verification(number: 1, provider_version: "5.4.3")
         | 
| 116 | 
            +
                          .create_provider("Provider2")
         | 
| 117 | 
            +
                          .create_pact
         | 
| 118 | 
            +
                          .create_verification(number: 1, provider_version: "6.5.4")
         | 
| 119 | 
            +
                          .create_consumer_version("2.0.0")
         | 
| 120 | 
            +
                          .create_pact
         | 
| 121 | 
            +
                      end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                      subject { Repository.new.find_latest_verification_for("Consumer1", "Provider1")}
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                      it "finds the latest verifications for the given consumer version" do
         | 
| 126 | 
            +
                        expect(subject.provider_version).to eq "7.8.9"
         | 
| 127 | 
            +
                      end
         | 
| 118 128 | 
             
                    end
         | 
| 119 129 |  | 
| 120 | 
            -
                     | 
| 130 | 
            +
                    context "when a tag is specified" do
         | 
| 131 | 
            +
                      before do
         | 
| 132 | 
            +
                        TestDataBuilder.new
         | 
| 133 | 
            +
                          .create_provider("Provider1")
         | 
| 134 | 
            +
                          .create_consumer("Consumer1")
         | 
| 135 | 
            +
                          .create_consumer_version("1.0.0")
         | 
| 136 | 
            +
                          .create_consumer_version_tag("prod")
         | 
| 137 | 
            +
                          .create_pact
         | 
| 138 | 
            +
                          .create_verification(number: 1, provider_version: "1.0.0")
         | 
| 139 | 
            +
                          .create_verification(number: 2, provider_version: "5.4.3")
         | 
| 140 | 
            +
                          .create_consumer_version("1.1.0")
         | 
| 141 | 
            +
                          .create_consumer_version_tag("prod")
         | 
| 142 | 
            +
                          .create_pact
         | 
| 143 | 
            +
                          .create_consumer_version("1.2.3")
         | 
| 144 | 
            +
                          .create_pact
         | 
| 145 | 
            +
                          .create_verification(number: 1, provider_version: "2.3.4")
         | 
| 146 | 
            +
                          .create_verification(number: 2, provider_version: "7.8.9")
         | 
| 147 | 
            +
                          .create_provider("Provider2")
         | 
| 148 | 
            +
                          .create_pact
         | 
| 149 | 
            +
                          .create_verification(number: 1, provider_version: "6.5.4")
         | 
| 150 | 
            +
                          .create_consumer_version("2.0.0")
         | 
| 151 | 
            +
                          .create_pact
         | 
| 152 | 
            +
                      end
         | 
| 121 153 |  | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 154 | 
            +
                      subject { Repository.new.find_latest_verification_for("Consumer1", "Provider1", 'prod')}
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                      it "finds the latest verifications for the given consumer version with the specified tag" do
         | 
| 157 | 
            +
                        expect(subject.provider_version).to eq "5.4.3"
         | 
| 158 | 
            +
                      end
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                      context "when no verification exists" do
         | 
| 161 | 
            +
                        subject { Repository.new.find_latest_verification_for("Consumer1", "Provider1", 'foo')}
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                        it "returns nil" do
         | 
| 164 | 
            +
                          expect(subject).to be nil
         | 
| 165 | 
            +
                        end
         | 
| 166 | 
            +
                      end
         | 
| 167 | 
            +
                    end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                    context "when the latest untagged verification is required" do
         | 
| 170 | 
            +
                      before do
         | 
| 171 | 
            +
                        TestDataBuilder.new
         | 
| 172 | 
            +
                          .create_provider("Provider1")
         | 
| 173 | 
            +
                          .create_consumer("Consumer1")
         | 
| 174 | 
            +
                          .create_consumer_version("1.0.0")
         | 
| 175 | 
            +
                          .create_pact
         | 
| 176 | 
            +
                          .create_verification(number: 1, provider_version: "1.0.0")
         | 
| 177 | 
            +
                          .create_verification(number: 2, provider_version: "5.4.3")
         | 
| 178 | 
            +
                          .create_consumer_version("1.1.0")
         | 
| 179 | 
            +
                          .create_consumer_version_tag("prod")
         | 
| 180 | 
            +
                          .create_pact
         | 
| 181 | 
            +
                          .create_consumer_version("1.2.3")
         | 
| 182 | 
            +
                          .create_consumer_version_tag("prod")
         | 
| 183 | 
            +
                          .create_pact
         | 
| 184 | 
            +
                          .create_verification(number: 1, provider_version: "2.3.4")
         | 
| 185 | 
            +
                          .create_verification(number: 2, provider_version: "7.8.9")
         | 
| 186 | 
            +
                          .create_provider("Provider2")
         | 
| 187 | 
            +
                          .create_pact
         | 
| 188 | 
            +
                          .create_verification(number: 1, provider_version: "6.5.4")
         | 
| 189 | 
            +
                          .create_consumer_version("2.0.0")
         | 
| 190 | 
            +
                          .create_pact
         | 
| 191 | 
            +
                      end
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                      subject { Repository.new.find_latest_verification_for("Consumer1", "Provider1", :untagged)}
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                      it "finds the latest verifications for the given consumer version with no tag" do
         | 
| 196 | 
            +
                        expect(subject.provider_version).to eq "5.4.3"
         | 
| 197 | 
            +
                      end
         | 
| 124 198 | 
             
                    end
         | 
| 125 199 | 
             
                  end
         | 
| 126 200 | 
             
                end
         | 
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require 'pact_broker/verifications/verification_status'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module PactBroker
         | 
| 4 | 
            +
              module Verifications
         | 
| 5 | 
            +
                describe Status do
         | 
| 6 | 
            +
                  describe "verification_status" do
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                    let(:latest_verification) { instance_double("PactBroker::Domain::Verification", pact_version_sha: latest_verification_pact_version_sha, success: success) }
         | 
| 9 | 
            +
                    let(:latest_pact) { instance_double("PactBroker::Domain::Pact", pact_version_sha: pact_pact_version_sha) }
         | 
| 10 | 
            +
                    let(:pact_pact_version_sha) { '1234' }
         | 
| 11 | 
            +
                    let(:latest_verification_pact_version_sha) { '1234' }
         | 
| 12 | 
            +
                    let(:success) { true }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    subject { PactBroker::Verifications::Status.new(latest_pact, latest_verification) }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    context "when the pact is nil (used in badge resource)" do
         | 
| 17 | 
            +
                      let(:latest_pact) { nil }
         | 
| 18 | 
            +
                      its(:to_sym) { is_expected.to eq :never }
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    context "when the pact has never been verified" do
         | 
| 22 | 
            +
                      let(:latest_verification) { nil }
         | 
| 23 | 
            +
                      its(:to_sym) { is_expected.to eq :never }
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    context "when the pact has not changed since the last successful verification" do
         | 
| 27 | 
            +
                      its(:to_sym) { is_expected.to eq :success }
         | 
| 28 | 
            +
                    end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                    context "when the pact has not changed since the last failed verification" do
         | 
| 31 | 
            +
                      let(:success) { false }
         | 
| 32 | 
            +
                      its(:to_sym) { is_expected.to eq :failed }
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    context "when the pact has changed since the last successful verification" do
         | 
| 36 | 
            +
                      let(:pact_pact_version_sha) { '4566' }
         | 
| 37 | 
            +
                      its(:to_sym) { is_expected.to eq :stale }
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    context "when the pact has changed since the last failed verification" do
         | 
| 41 | 
            +
                      let(:pact_pact_version_sha) { '4566' }
         | 
| 42 | 
            +
                      let(:success) { false }
         | 
| 43 | 
            +
                      its(:to_sym) { is_expected.to eq :failed }
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
            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: 2. | 
| 4 | 
            +
              version: 2.3.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-07- | 
| 13 | 
            +
            date: 2017-07-14 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: httparty
         | 
| @@ -519,6 +519,7 @@ files: | |
| 519 519 | 
             
            - lib/pact_broker/api/pact_broker_urls.rb
         | 
| 520 520 | 
             
            - lib/pact_broker/api/renderers/html_pact_renderer.rb
         | 
| 521 521 | 
             
            - lib/pact_broker/api/resources/authentication.rb
         | 
| 522 | 
            +
            - lib/pact_broker/api/resources/badge.rb
         | 
| 522 523 | 
             
            - lib/pact_broker/api/resources/base_resource.rb
         | 
| 523 524 | 
             
            - lib/pact_broker/api/resources/group.rb
         | 
| 524 525 | 
             
            - lib/pact_broker/api/resources/index.rb
         | 
| @@ -545,6 +546,7 @@ files: | |
| 545 546 | 
             
            - lib/pact_broker/api/resources/webhook_resource_methods.rb
         | 
| 546 547 | 
             
            - lib/pact_broker/api/resources/webhooks.rb
         | 
| 547 548 | 
             
            - lib/pact_broker/app.rb
         | 
| 549 | 
            +
            - lib/pact_broker/badges/service.rb
         | 
| 548 550 | 
             
            - lib/pact_broker/config/load.rb
         | 
| 549 551 | 
             
            - lib/pact_broker/config/save.rb
         | 
| 550 552 | 
             
            - lib/pact_broker/config/setting.rb
         | 
| @@ -639,6 +641,7 @@ files: | |
| 639 641 | 
             
            - lib/pact_broker/verifications/repository.rb
         | 
| 640 642 | 
             
            - lib/pact_broker/verifications/service.rb
         | 
| 641 643 | 
             
            - lib/pact_broker/verifications/summary_for_consumer_version.rb
         | 
| 644 | 
            +
            - lib/pact_broker/verifications/verification_status.rb
         | 
| 642 645 | 
             
            - lib/pact_broker/version.rb
         | 
| 643 646 | 
             
            - lib/pact_broker/versions/parse_semantic_version.rb
         | 
| 644 647 | 
             
            - lib/pact_broker/versions/repository.rb
         | 
| @@ -672,6 +675,11 @@ files: | |
| 672 675 | 
             
            - public/fonts/glyphicons-halflings-regular.woff
         | 
| 673 676 | 
             
            - public/images/doc-text.svg
         | 
| 674 677 | 
             
            - public/images/favicon.ico
         | 
| 678 | 
            +
            - public/images/pact-changed-orange.svg
         | 
| 679 | 
            +
            - public/images/pact-failed-red.svg
         | 
| 680 | 
            +
            - public/images/pact-unknown-lightgrey.svg
         | 
| 681 | 
            +
            - public/images/pact-verified-brightgreen.svg
         | 
| 682 | 
            +
            - public/images/pact_not_found-unknown-lightgrey.svg
         | 
| 675 683 | 
             
            - public/javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js
         | 
| 676 684 | 
             
            - public/javascripts/highlight.pack.js
         | 
| 677 685 | 
             
            - public/javascripts/jquery-2.1.1.min.js
         | 
| @@ -696,7 +704,10 @@ files: | |
| 696 704 | 
             
            - spec/features/delete_version_spec.rb
         | 
| 697 705 | 
             
            - spec/features/delete_webhook_spec.rb
         | 
| 698 706 | 
             
            - spec/features/get_diff_spec.rb
         | 
| 707 | 
            +
            - spec/features/get_latest_pact_badge_spec.rb
         | 
| 708 | 
            +
            - spec/features/get_latest_tagged_pact_badge_spec.rb
         | 
| 699 709 | 
             
            - spec/features/get_latest_tagged_pact_spec.rb
         | 
| 710 | 
            +
            - spec/features/get_latest_untagged_pact_badge_spec.rb
         | 
| 700 711 | 
             
            - spec/features/get_latest_untagged_pact_spec.rb
         | 
| 701 712 | 
             
            - spec/features/get_pact_spec.rb
         | 
| 702 713 | 
             
            - spec/features/get_pact_versions_spec.rb
         | 
| @@ -746,6 +757,7 @@ files: | |
| 746 757 | 
             
            - spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb
         | 
| 747 758 | 
             
            - spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
         | 
| 748 759 | 
             
            - spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb
         | 
| 760 | 
            +
            - spec/lib/pact_broker/api/resources/badge_spec.rb
         | 
| 749 761 | 
             
            - spec/lib/pact_broker/api/resources/group_spec.rb
         | 
| 750 762 | 
             
            - spec/lib/pact_broker/api/resources/latest_pact_spec.rb
         | 
| 751 763 | 
             
            - spec/lib/pact_broker/api/resources/latest_verifications_for_consumer_version_spec.rb
         | 
| @@ -759,6 +771,7 @@ files: | |
| 759 771 | 
             
            - spec/lib/pact_broker/api/resources/webhook_spec.rb
         | 
| 760 772 | 
             
            - spec/lib/pact_broker/api/resources/webhooks_spec.rb
         | 
| 761 773 | 
             
            - spec/lib/pact_broker/app_spec.rb
         | 
| 774 | 
            +
            - spec/lib/pact_broker/badges/service_spec.rb
         | 
| 762 775 | 
             
            - spec/lib/pact_broker/config/load_spec.rb
         | 
| 763 776 | 
             
            - spec/lib/pact_broker/config/save_and_load_spec.rb
         | 
| 764 777 | 
             
            - spec/lib/pact_broker/config/save_spec.rb
         | 
| @@ -796,6 +809,7 @@ files: | |
| 796 809 | 
             
            - spec/lib/pact_broker/verifications/repository_spec.rb
         | 
| 797 810 | 
             
            - spec/lib/pact_broker/verifications/service_spec.rb
         | 
| 798 811 | 
             
            - spec/lib/pact_broker/verifications/summary_for_consumer_version_spec.rb
         | 
| 812 | 
            +
            - spec/lib/pact_broker/verifications/verification_status_spec.rb
         | 
| 799 813 | 
             
            - spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
         | 
| 800 814 | 
             
            - spec/lib/pact_broker/versions/repository_spec.rb
         | 
| 801 815 | 
             
            - spec/lib/pact_broker/versions/service_spec.rb
         | 
| @@ -892,7 +906,10 @@ test_files: | |
| 892 906 | 
             
            - spec/features/delete_version_spec.rb
         | 
| 893 907 | 
             
            - spec/features/delete_webhook_spec.rb
         | 
| 894 908 | 
             
            - spec/features/get_diff_spec.rb
         | 
| 909 | 
            +
            - spec/features/get_latest_pact_badge_spec.rb
         | 
| 910 | 
            +
            - spec/features/get_latest_tagged_pact_badge_spec.rb
         | 
| 895 911 | 
             
            - spec/features/get_latest_tagged_pact_spec.rb
         | 
| 912 | 
            +
            - spec/features/get_latest_untagged_pact_badge_spec.rb
         | 
| 896 913 | 
             
            - spec/features/get_latest_untagged_pact_spec.rb
         | 
| 897 914 | 
             
            - spec/features/get_pact_spec.rb
         | 
| 898 915 | 
             
            - spec/features/get_pact_versions_spec.rb
         | 
| @@ -942,6 +959,7 @@ test_files: | |
| 942 959 | 
             
            - spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb
         | 
| 943 960 | 
             
            - spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb
         | 
| 944 961 | 
             
            - spec/lib/pact_broker/api/renderers/html_pact_renderer_spec.rb
         | 
| 962 | 
            +
            - spec/lib/pact_broker/api/resources/badge_spec.rb
         | 
| 945 963 | 
             
            - spec/lib/pact_broker/api/resources/group_spec.rb
         | 
| 946 964 | 
             
            - spec/lib/pact_broker/api/resources/latest_pact_spec.rb
         | 
| 947 965 | 
             
            - spec/lib/pact_broker/api/resources/latest_verifications_for_consumer_version_spec.rb
         | 
| @@ -955,6 +973,7 @@ test_files: | |
| 955 973 | 
             
            - spec/lib/pact_broker/api/resources/webhook_spec.rb
         | 
| 956 974 | 
             
            - spec/lib/pact_broker/api/resources/webhooks_spec.rb
         | 
| 957 975 | 
             
            - spec/lib/pact_broker/app_spec.rb
         | 
| 976 | 
            +
            - spec/lib/pact_broker/badges/service_spec.rb
         | 
| 958 977 | 
             
            - spec/lib/pact_broker/config/load_spec.rb
         | 
| 959 978 | 
             
            - spec/lib/pact_broker/config/save_and_load_spec.rb
         | 
| 960 979 | 
             
            - spec/lib/pact_broker/config/save_spec.rb
         | 
| @@ -992,6 +1011,7 @@ test_files: | |
| 992 1011 | 
             
            - spec/lib/pact_broker/verifications/repository_spec.rb
         | 
| 993 1012 | 
             
            - spec/lib/pact_broker/verifications/service_spec.rb
         | 
| 994 1013 | 
             
            - spec/lib/pact_broker/verifications/summary_for_consumer_version_spec.rb
         | 
| 1014 | 
            +
            - spec/lib/pact_broker/verifications/verification_status_spec.rb
         | 
| 995 1015 | 
             
            - spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
         | 
| 996 1016 | 
             
            - spec/lib/pact_broker/versions/repository_spec.rb
         | 
| 997 1017 | 
             
            - spec/lib/pact_broker/versions/service_spec.rb
         |