report_test.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'test_helper'
  2. class ReportTest < Test::Unit::TestCase
  3. test 'get should get a report' do
  4. fake('reports/987', method: :get, status: 200, body: load_fixture('report'))
  5. report = ShopifyAPI::Report.find(987)
  6. assert_equal(987, report.id)
  7. end
  8. test 'get all should get all reports' do
  9. fake('reports', method: :get, status: 200, body: load_fixture('reports'))
  10. reports = ShopifyAPI::Report.all
  11. assert_equal('custom_app_reports', reports.first.category)
  12. end
  13. test 'create should create a report' do
  14. fake('reports', method: :post, status: 201, body: load_fixture('report'))
  15. report = ShopifyAPI::Report.create(
  16. name: 'Custom App Report',
  17. shopify_ql: 'SHOW quantity_count, total_sales BY product_type, vendor, product_title ' \
  18. 'FROM products SINCE -1m UNTIL -0m ORDER BY total_sales DESC'
  19. )
  20. assert_equal('custom_app_reports', report.category)
  21. end
  22. test 'delete should delete report' do
  23. fake('reports/987', method: :get, status: 200, body: load_fixture('report'))
  24. fake('reports/987', method: :delete, status: 200, body: '[]')
  25. report = ShopifyAPI::Report.find(987)
  26. assert(report.destroy)
  27. end
  28. end