article_test.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_authors_for_blog_id
  30. fake "blogs/1008414260/articles/authors", :method => :get, :body => load_fixture('authors')
  31. authors = ShopifyAPI::Article.authors(:blog_id => 1008414260)
  32. assert_equal 3, authors.length
  33. end
  34. def test_get_tags
  35. fake "articles/tags", :method => :get, :body => load_fixture('tags')
  36. tags = ShopifyAPI::Article.tags
  37. assert_equal "consequuntur", tags.first
  38. assert_equal "repellendus", tags.last
  39. end
  40. def test_get_tags_for_blog_id
  41. fake "blogs/1008414260/articles/tags", :method => :get, :body => load_fixture('tags')
  42. tags = ShopifyAPI::Article.tags(:blog_id => 1008414260)
  43. assert_equal "consequuntur", tags.first
  44. assert_equal "repellendus", tags.last
  45. end
  46. def test_get_popular_tags
  47. fake "articles/tags.json?limit=1&popular=1", :extension => false, :method => :get, :body => load_fixture('tags')
  48. tags = ShopifyAPI::Article.tags(:popular => 1, :limit => 1)
  49. assert_equal 3, tags.length
  50. end
  51. end