Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
jsonapi-resources / test / integration / sti_fields_test.rb
Size: Mime:
require File.expand_path("../../test_helper", __FILE__)

class StiFieldsTest < ActionDispatch::IntegrationTest
  def test_index_fields_when_resource_does_not_match_relationship
    get "/posts", params: { 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", params: { fields: { companies: "name" } }
    assert_equal json_response["data"][0]["attributes"].keys, ["name"]
  end
end