scinote-web/spec/jobs/activities/dispatch_webhooks_job_spec.rb

26 lines
877 B
Ruby
Raw Normal View History

2021-06-17 20:54:30 +08:00
# frozen_string_literal: true
require 'rails_helper'
describe Activities::DispatchWebhooksJob do
let!(:activity_filter_1) { create :activity_filter }
let!(:activity_filter_2) { create :activity_filter }
let!(:non_matching_activity_filter) do
2021-06-30 19:08:16 +08:00
create(
:activity_filter,
filter: { 'types' => ['163'], 'from_date' => '', 'to_date' => '' }
2021-06-17 20:54:30 +08:00
)
end
let!(:webhook_1) { create :webhook, activity_filter: activity_filter_1 }
let!(:webhook_2) { create :webhook, activity_filter: activity_filter_2 }
let!(:webhook_3) { create :webhook, activity_filter: non_matching_activity_filter }
let(:activity) { create :activity }
2021-06-17 20:54:30 +08:00
it 'enqueues webhook jobs' do
ActiveJob::Base.queue_adapter = :test
2021-06-30 19:08:16 +08:00
expect { Activities::DispatchWebhooksJob.new(activity).perform_now }
.to have_enqueued_job(Activities::SendWebhookJob).exactly(2).times
2021-06-17 20:54:30 +08:00
end
end