webhook_test.rb 867 B

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