webhook_test.rb 874 B

123456789101112131415161718192021
  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(address: "http://www.yoloship.it/webhook",topic: "orders/create",format: "json")
  6. assert_equal "http://www.yoloship.it/webhook", webhook.address
  7. end
  8. test 'get should retrieve a webhook' do
  9. fake 'webhooks/123456', :method => :get, :status => 200, :body => load_fixture('webhook')
  10. webhook = ShopifyAPI::Webhook.find(123456)
  11. assert_equal "http://www.yoloship.it/webhook", webhook.address
  12. end
  13. test 'find all should return all webhooks' do
  14. fake 'webhooks', :method => :get, :status => 200, :body => load_fixture('webhooks')
  15. webhook = ShopifyAPI::Webhook.all
  16. assert_equal 123456, webhook.first.id
  17. end
  18. end