image_test.rb 1.0 KB

123456789101112131415161718192021222324252627
  1. require 'test_helper'
  2. require 'uri'
  3. class ImageTest < Test::Unit::TestCase
  4. def test_create_image
  5. fake "products/632910392/images", :method => :post, :body => load_fixture('image')
  6. image = ShopifyAPI::Image.new(:product_id => 632910392)
  7. image.position = 1
  8. image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3MNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf=="
  9. image.save
  10. assert_equal 'http://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1389388540', image.src
  11. assert_equal 850703190, image.id
  12. end
  13. def test_get_images
  14. fake "products/632910392/images", :method => :get, :body => load_fixture('images')
  15. image = ShopifyAPI::Image.find(:all, :params => {:product_id => 632910392})
  16. assert_equal 2, image.size
  17. end
  18. def test_get_image
  19. fake "products/632910392/images/850703190", :method => :get, :body => load_fixture('image')
  20. image = ShopifyAPI::Image.find(850703190, :params => {:product_id => 632910392})
  21. assert_equal 850703190, image.id
  22. end
  23. end