collection_publication_test.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class CollectionPublicationTest < Test::Unit::TestCase
  4. def test_get_all_collection_publications
  5. fake('publications/55650051/collection_publications', body: load_fixture('collection_publications'))
  6. collection_publications = ShopifyAPI::CollectionPublication.find(:all, params: { publication_id: 55650051 })
  7. assert_equal(96062799894, collection_publications.first.id)
  8. assert_equal(55650051, collection_publications.first.publication_id)
  9. end
  10. def test_get_collection_publication
  11. fake('publications/55650051/collection_publications/647162527768', body: load_fixture('collection_publication'))
  12. collection_publication = ShopifyAPI::CollectionPublication.find(647162527768, params: { publication_id: 55650051 })
  13. assert_equal(96062799894, collection_publication.id)
  14. assert_equal(55650051, collection_publication.publication_id)
  15. end
  16. def test_create_collection_publication
  17. fake('publications/55650051/collection_publications', method: :post, body: load_fixture('collection_publication'))
  18. ShopifyAPI::CollectionPublication.create(
  19. publication_id: 55650051,
  20. published_at: "2018-01-29T14:06:08-05:00",
  21. published: true,
  22. collection_id: 8267093571
  23. )
  24. expected_body = {
  25. collection_publication: {
  26. published_at: "2018-01-29T14:06:08-05:00",
  27. published: true,
  28. collection_id: 8267093571,
  29. },
  30. }.to_json
  31. assert_equal(expected_body, WebMock.last_request.body)
  32. end
  33. end