webhook_test.rb 897 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class WebhookTest < Test::Unit::TestCase
  4. test 'create should create a webhook' do
  5. fake('webhooks', method: :post, status: 201, body: load_fixture('webhook'))
  6. webhook = ShopifyAPI::Webhook.create(
  7. address: "http://www.yoloship.it/webhook", topic: "orders/create", format: "json"
  8. )
  9. assert_equal("http://www.yoloship.it/webhook", webhook.address)
  10. end
  11. test 'get should retrieve a webhook' do
  12. fake('webhooks/123456', method: :get, status: 200, body: load_fixture('webhook'))
  13. webhook = ShopifyAPI::Webhook.find(123456)
  14. assert_equal("http://www.yoloship.it/webhook", webhook.address)
  15. end
  16. test 'find all should return all webhooks' do
  17. fake('webhooks', method: :get, status: 200, body: load_fixture('webhooks'))
  18. webhook = ShopifyAPI::Webhook.all
  19. assert_equal(123456, webhook.first.id)
  20. end
  21. end