Sha256: 2fa66722e538cf65b77db172fdec5901d1d37e70017cdbb58c62b4368951fd2e

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
require 'test_helper'

class ReportTest < Test::Unit::TestCase
  test 'get should get a report' do
    fake('reports/987', method: :get, status: 200, body: load_fixture('report'))

    report = ShopifyAPI::Report.find(987)
    assert_equal(987, report.id)
  end

  test 'get all should get all reports' do
    fake('reports', method: :get, status: 200, body: load_fixture('reports'))

    reports = ShopifyAPI::Report.all
    assert_equal('custom_app_reports', reports.first.category)
  end

  test 'create should create a report' do
    fake('reports', method: :post, status: 201, body: load_fixture('report'))

    report = ShopifyAPI::Report.create(
      name: 'Custom App Report',
      shopify_ql: 'SHOW quantity_count, total_sales BY product_type, vendor, product_title ' \
        'FROM products SINCE -1m UNTIL -0m ORDER BY total_sales DESC'
    )
    assert_equal('custom_app_reports', report.category)
  end

  test 'delete should delete report' do
    fake('reports/987', method: :get, status: 200, body: load_fixture('report'))
    fake('reports/987', method: :delete, status: 200, body: '[]')

    report = ShopifyAPI::Report.find(987)
    assert(report.destroy)
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
shopify_api-9.5.2 test/report_test.rb
ruby_shopify_api-1.2.0 test/report_test.rb
ruby_shopify_api-1.1.0 test/report_test.rb
ruby_shopify_api-1.0.0 test/report_test.rb
shopify_api-9.5.1 test/report_test.rb
shopify_api-9.5 test/report_test.rb
shopify_api-9.4.1 test/report_test.rb
shopify_api-9.4.0 test/report_test.rb
shopify_api-9.3.0 test/report_test.rb