Sha256: 5968b2307eb756d489cf719cdb01358c04872fad373cb108ecbf03eb5bc3ad4b

Contents?: true

Size: 1.43 KB

Versions: 69

Compression:

Stored size: 1.43 KB

Contents

require 'pact_broker/webhooks/webhook'

module PactBroker
  module Webhooks
    describe Webhook do

      let(:td) { TestDataBuilder.new }

      before do
        td.create_consumer("Foo")
          .create_provider("Bar")
          .create_consumer_version
          .create_pact
          .create_global_webhook
          .create_consumer_webhook
          .create_provider_webhook
          .create_provider("Wiffle")
          .create_provider_webhook
      end

      let(:consumer) { PactBroker::Domain::Pacticipant.find(name: "Foo") }
      let(:provider) { PactBroker::Domain::Pacticipant.find(name: "Bar") }
      let(:pact) { double(consumer_id: consumer.id, provider_id: provider.id).as_null_object }

      describe "#is_for?" do
        let(:matching_webhook_uuids) { Webhooks::Repository.new.find_by_consumer_and_or_provider(consumer, provider).collect(&:uuid) }
        let(:matching_webhooks) { Webhooks::Webhook.where(uuid: matching_webhook_uuids) }
        let(:non_matching_webhooks) { Webhooks::Webhook.exclude(uuid: matching_webhook_uuids) }

        it "matches the implementation of Webhook::Repository#find_by_consumer_and_or_provider" do
          expect(matching_webhooks.count).to be > 0
          expect(non_matching_webhooks.count).to be > 0
          expect(matching_webhooks.all?{|w| w.is_for?(pact)}).to be true
          expect(non_matching_webhooks.all?{|w| !w.is_for?(pact)}).to be true
        end
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
pact_broker-2.52.1 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.52.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.51.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.50.1 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.50.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.49.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.48.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.47.1 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.47.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.46.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.45.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.44.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.43.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.42.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.41.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.40.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.39.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.38.1 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.38.0 spec/lib/pact_broker/webhooks/webhook_spec.rb
pact_broker-2.37.0 spec/lib/pact_broker/webhooks/webhook_spec.rb