report_test.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 FROM products SINCE -1m UNTIL -0m ORDER BY total_sales DESC'
  18. )
  19. assert_equal 'custom_app_reports', report.category
  20. end
  21. test 'delete should delete report' do
  22. fake 'reports/987', method: :get, status: 200, body: load_fixture('report')
  23. fake 'reports/987', method: :delete, status: 200, body: '[]'
  24. report = ShopifyAPI::Report.find(987)
  25. assert report.destroy
  26. end
  27. end