Sha256: 51ff0222e937854b7f9b8c8dae3f5cc75c267a7e162ee61da8985c9f8a0be7aa

Contents?: true

Size: 713 Bytes

Versions: 5

Compression:

Stored size: 713 Bytes

Contents

require File.expand_path("../../test_helper", __FILE__)

class StiFieldsTest < ActionDispatch::IntegrationTest
  def test_index_fields_when_resource_does_not_match_relationship
    get "/posts", { filter: { id: "1,2" },
                  include: "author",
                  fields: { posts: "author", people: "email" } }
    assert_response :success
    assert_equal 2, json_response["data"].size
    assert json_response["data"][0]["relationships"].key?("author")
    assert json_response["included"][0]["attributes"].keys == ["email"]
  end

  def test_fields_for_parent_class
    get "/firms", { fields: { companies: "name" } }
    assert_equal json_response["data"][0]["attributes"].keys, ["name"]
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jsonapi-resources-0.7.1.beta1 test/integration/sti_fields_test.rb
jsonapi-resources-0.7.0 test/integration/sti_fields_test.rb
jsonapi-resources-0.6.2 test/integration/sti_fields_test.rb
jsonapi-resources-0.6.1 test/integration/sti_fields_test.rb
jsonapi-resources-0.6.0 test/integration/sti_fields_test.rb