diff --git a/db/migrations/20180109_migrate_trigger_type.rb b/db/migrations/20180109_migrate_trigger_type.rb new file mode 100644 index 000000000..7e8f6ae2c --- /dev/null +++ b/db/migrations/20180109_migrate_trigger_type.rb @@ -0,0 +1,9 @@ +Sequel.migration do + up do + from(:triggered_webhooks).where(trigger_type: 'pact_publication').update(trigger_type: 'publication') + end + + down do + from(:triggered_webhooks).where(trigger_type: 'publication').update(trigger_type: 'pact_publication') + end +end diff --git a/lib/pact_broker/webhooks/triggered_webhook.rb b/lib/pact_broker/webhooks/triggered_webhook.rb index 3bfab4e96..1ce46520a 100644 --- a/lib/pact_broker/webhooks/triggered_webhook.rb +++ b/lib/pact_broker/webhooks/triggered_webhook.rb @@ -6,7 +6,7 @@ module PactBroker module Webhooks class TriggeredWebhook < Sequel::Model(:triggered_webhooks) - TRIGGER_TYPE_PUBLICATION = 'pact_publication' + TRIGGER_TYPE_PUBLICATION = 'publication' TRIGGER_TYPE_USER = 'user' STATUS_NOT_RUN = 'not_run'.freeze diff --git a/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb b/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb index 26f8a08db..3efff3a16 100644 --- a/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb +++ b/spec/lib/pact_broker/api/decorators/pact_webhooks_status_decorator_spec.rb @@ -61,7 +61,7 @@ module Decorators it "includes the triggered webhooks properties" do expect(subject[:_embedded][:triggeredWebhooks].first).to include( status: 'success', - triggerType: 'pact_publication', + triggerType: 'publication', attemptsMade: 1, attemptsRemaining: 2 ) diff --git a/spec/lib/pact_broker/webhooks/repository_spec.rb b/spec/lib/pact_broker/webhooks/repository_spec.rb index 8d4532cd4..1cb045e2c 100644 --- a/spec/lib/pact_broker/webhooks/repository_spec.rb +++ b/spec/lib/pact_broker/webhooks/repository_spec.rb @@ -335,14 +335,14 @@ module Webhooks .create_pact end - subject { Repository.new.create_triggered_webhook '1234', td.webhook, td.pact, 'pact_publication' } + subject { Repository.new.create_triggered_webhook '1234', td.webhook, td.pact, 'publication' } it "creates a TriggeredWebhook" do expect(subject.webhook_uuid ).to eq td.webhook.uuid expect(subject.consumer).to eq td.consumer expect(subject.provider).to eq td.provider expect(subject.trigger_uuid).to eq '1234' - expect(subject.trigger_type).to eq 'pact_publication' + expect(subject.trigger_type).to eq 'publication' end it "sets the webhook" do