resource_feedback_test.rb 1020 B

12345678910111213141516171819202122232425262728
  1. class ResourceFeedbackTest < Test::Unit::TestCase
  2. def test_save_with_resource_feedbacks_endpoint
  3. body = { resource_feedback: {} }.to_json
  4. fake 'resource_feedbacks', method: :post, body: body
  5. ShopifyAPI::ResourceFeedback.new.save
  6. assert_request_body body
  7. end
  8. def test_save_with_product_id_resource_feedbacks_endpoint
  9. body = { resource_feedback: {} }.to_json
  10. fake 'products/42/resource_feedbacks', method: :post, body: body
  11. ShopifyAPI::ResourceFeedback.new(product_id: 42).save
  12. assert_request_body body
  13. end
  14. def test_save_raises_exception_when_already_persisted
  15. body = { resource_feedback: {} }.to_json
  16. fake 'resource_feedbacks', method: :post, body: body
  17. resource_feedback = ShopifyAPI::ResourceFeedback.new
  18. resource_feedback.save
  19. assert_request_body body
  20. ShopifyAPI::ResourceFeedback.any_instance.expects(:persisted?).returns(true)
  21. assert_raises ShopifyAPI::ResourceFeedback::ExistingFeedbackSaved do
  22. resource_feedback.save
  23. end
  24. end
  25. end