article_test.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. require 'test_helper'
  2. class ArticleTest < Test::Unit::TestCase
  3. def test_get_article
  4. fake "articles/6242736", :method => :get, :body => load_fixture('article')
  5. article = ShopifyAPI::Article.find(6242736)
  6. assert_equal "First Post", article.title
  7. end
  8. def test_get_articles
  9. fake "articles", :method => :get, :body => load_fixture('articles')
  10. articles = ShopifyAPI::Article.all
  11. assert_equal 3, articles.length
  12. end
  13. def test_get_articles_namespaced
  14. fake "blogs/1008414260/articles", :method => :get, :body => load_fixture('articles')
  15. articles = ShopifyAPI::Article.find(:all, :params => {:blog_id => 1008414260})
  16. assert_equal 3, articles.length
  17. end
  18. def test_get_article_namespaced
  19. fake "blogs/1008414260/articles/6242736", :method => :get, :body => load_fixture('article')
  20. article = ShopifyAPI::Article.find(6242736, :params => {:blog_id => 1008414260})
  21. assert_equal "First Post", article.title
  22. end
  23. def test_get_authors
  24. fake "articles/authors", :method => :get, :body => load_fixture('authors')
  25. authors = ShopifyAPI::Article.authors
  26. assert_equal "Shopify", authors.first
  27. assert_equal "development shop", authors.last
  28. end
  29. def test_get_tags
  30. fake "articles/tags", :method => :get, :body => load_fixture('tags')
  31. tags = ShopifyAPI::Article.tags
  32. assert_equal "consequuntur", tags.first
  33. assert_equal "repellendus", tags.last
  34. end
  35. def test_get_tags_for_blog_id
  36. fake "blogs/1008414260/articles/tags", :method => :get, :body => load_fixture('tags')
  37. tags = ShopifyAPI::Article.tags(:blog_id => 1008414260)
  38. assert_equal "consequuntur", tags.first
  39. assert_equal "repellendus", tags.last
  40. end
  41. def test_get_popular_tags
  42. fake "articles/tags.json?limit=1&popular=1", :extension => false, :method => :get, :body => load_fixture('tags')
  43. tags = ShopifyAPI::Article.tags(:popular => 1, :limit => 1)
  44. puts tags
  45. end
  46. end