report_test.rb 1.2 KB

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