Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Last active August 26, 2015 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcardarella/06184cf78c45f2cfd1b9 to your computer and use it in GitHub Desktop.
Save bcardarella/06184cf78c45f2cfd1b9 to your computer and use it in GitHub Desktop.
defmodule BelongsToReferenceKeyTest do
use ExUnit.Case
defmodule Foo do
use Ecto.Model
@primary_key {:foobar_id, :id, []}
schema "foos" do
belongs_to :bar, Bar
end
end
defmodule Bar do
use Ecto.Model
schema "bars" do
has_one :foo, Foo
end
end
test "related_key should be equal to the related module's primary key" do
assoc = Foo.__schema__(:association, :bar)
assert assoc.related_key == List.first(assoc.related.__schema__(:primary_key))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment