abandoned_checkouts_test.rb 952 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class AbandonedCheckoutsTest < Test::Unit::TestCase
  4. def setup
  5. super
  6. @expected_checkouts = JSON.parse(load_fixture('abandoned_checkouts'))['checkouts']
  7. @expected_checkout_id = JSON.parse(load_fixture('abandoned_checkout'))['checkout']['id']
  8. end
  9. test ":create creates a checkout" do
  10. fake 'checkouts', method: :post, status: 201, body: load_fixture('abandoned_checkout')
  11. checkout = ShopifyAPI::AbandonedCheckout.create
  12. assert_equal @expected_checkout_id, checkout.id
  13. assert_equal true, checkout.attributes.include?(:abandoned_checkout_url)
  14. end
  15. test "get all checkouts indexed by token" do
  16. fake 'checkouts', method: :get, status: 200, body: load_fixture('abandoned_checkouts')
  17. checkouts = ShopifyAPI::AbandonedCheckout.all
  18. assert_equal @expected_checkout_id, checkouts.first.id
  19. assert_equal @expected_checkouts.size, checkouts.size
  20. end
  21. end