json_errors_test.rb 626 B

123456789101112131415161718
  1. require 'test_helper'
  2. module ActiveResource
  3. class JsonErrorsTest < Test::Unit::TestCase
  4. def test_parsing_of_error_json_hash
  5. @model = ShopifyAPI::Order.new
  6. @model.errors.from_json({ errors: { name: ['missing'] } }.to_json)
  7. assert_equal(['missing'], @model.errors[:name])
  8. end
  9. def test_parsing_of_error_json_plain_string
  10. @model = ShopifyAPI::Order.new
  11. @model.errors.from_json({ errors: 'some generic error' }.to_json)
  12. assert_equal(['some generic error'], @model.errors[:base])
  13. assert_equal('some generic error', @model.errors.full_messages.to_sentence)
  14. end
  15. end
  16. end