order_risk_test.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class OrderRiskTest < Test::Unit::TestCase
  4. def test_create_order_risk
  5. fake("orders/450789469/risks", method: :post, body: load_fixture('order_risk'))
  6. v = ShopifyAPI::OrderRisk.new(order_id: 450789469)
  7. v.message = "This order was placed from a proxy IP"
  8. v.recommendation = "cancel"
  9. v.score = "1.0"
  10. v.source = "External"
  11. v.merchant_message = "This order was placed from a proxy IP"
  12. v.display = true
  13. v.cause_cancel = true
  14. v.save
  15. assert_equal(284138680, v.id)
  16. end
  17. def test_get_order_risks
  18. fake("orders/450789469/risks", method: :get, body: load_fixture('order_risks'))
  19. v = ShopifyAPI::OrderRisk.find(:all, params: { order_id: 450789469 })
  20. assert_equal(2, v.size)
  21. end
  22. def test_get_order_risk
  23. fake("orders/450789469/risks/284138680", method: :get, body: load_fixture('order_risk'))
  24. v = ShopifyAPI::OrderRisk.find(284138680, params: { order_id: 450789469 })
  25. assert_equal(284138680, v.id)
  26. end
  27. def test_delete_order_risk
  28. fake("orders/450789469/risks/284138680", method: :get, body: load_fixture('order_risk'))
  29. fake("orders/450789469/risks/284138680", method: :delete, body: "destroyed")
  30. v = ShopifyAPI::OrderRisk.find(284138680, params: { order_id: 450789469 })
  31. assert(v.destroy)
  32. end
  33. def test_update_order_risk
  34. fake("orders/450789469/risks/284138680", method: :get, body: load_fixture('order_risk'))
  35. fake("orders/450789469/risks/284138680", method: :put, body: load_fixture('order_risk'))
  36. v = ShopifyAPI::OrderRisk.find(284138680, params: { order_id: 450789469 })
  37. v.position = 3
  38. v.save
  39. end
  40. end