Sha256: 6a8374e849e16a23ac6d896ca7f265502f5ffe7f44c71192f8830a1b4addc463

Contents?: true

Size: 910 Bytes

Versions: 5

Compression:

Stored size: 910 Bytes

Contents

require_relative '../../test_helper'

class ActiveRecord::RecordNotFoundSerializerTest < Minitest::Spec
  let(:error) do
    ActiveRecord::RecordNotFound.new("a message", "Thing", "id", 1)
  end

  let(:serialized_error) do
    SimpleJsonapi.render_errors(error).dig(:errors, 0)
  end

  describe SimpleJsonapi::Errors::ActiveRecord::RecordNotFoundSerializer do
    it "has a status of 404" do
      assert_equal "404", serialized_error[:status]
    end

    it "has a code of not_found" do
      assert_equal "not_found", serialized_error[:code]
    end

    it "has a title of Not found" do
      assert_equal "Not found", serialized_error[:title]
    end

    it "has the full message as the detail" do
      assert_equal "a message", serialized_error[:detail]
    end

    it "has the primary key as the source parameter" do
      assert_equal "id", serialized_error[:source][:parameter]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_jsonapi_rails-1.3.0 test/errors/active_record/record_not_found_serializer_test.rb
simple_jsonapi_rails-1.2.0 test/errors/active_record/record_not_found_serializer_test.rb
simple_jsonapi_rails-1.1.1 test/errors/active_record/record_not_found_serializer_test.rb
simple_jsonapi_rails-1.1.0 test/errors/active_record/record_not_found_serializer_test.rb
simple_jsonapi_rails-1.0.0 test/errors/active_record/record_not_found_serializer_test.rb