json_errors_test.rb 656 B

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