Sha256: a7c9866897f8bc2e5c25576a5ff1e10aa0b4e9f1c9e42de4ac6af6a0c0798f8d
Contents?: true
Size: 1.35 KB
Versions: 10
Compression:
Stored size: 1.35 KB
Contents
require 'test_helper' class DiscoApp::SynchroniseWebhooksJobTest < ActionController::TestCase include ActiveJob::TestHelper def setup @shop = disco_app_shops(:widget_store) end def teardown @shop = nil WebMock.reset! end test 'webhook synchronisation job creates webhooks for all expected topics' do stub_request(:get, "#{@shop.admin_url}/webhooks.json").to_return(status: 200, body: api_fixture('widget_store/webhooks').to_json) stub_request(:post, "#{@shop.admin_url}/webhooks.json").to_return(status: 200) perform_enqueued_jobs do DiscoApp::SynchroniseWebhooksJob.perform_later(@shop) end # Assert that all 4 expected webhook topics were POSTed to. ['app/uninstalled', 'shop/update', 'orders/create', 'orders/paid'].each do |expected_webhook_topic| assert_requested(:post, "#{@shop.admin_url}/webhooks.json", times: 1) { |request| request.body.include?(expected_webhook_topic) } end end test 'returns error messages for webhooks that cannot be registered' do VCR.use_cassette('webhook_failure') do output = capture_io do perform_enqueued_jobs do DiscoApp::SynchroniseWebhooksJob.perform_later(@shop) end end assert output.first.include?('Invalid topic specified.') assert output.first.include?('orders/create - not registered') end end end
Version data entries
10 entries across 10 versions & 1 rubygems