Last active
August 26, 2015 13:48
-
-
Save bcardarella/06184cf78c45f2cfd1b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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