Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions test/ecto_typed_schema/types/has_one_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ defmodule EctoTypedSchema.Types.HasOneTest do
end
end

defmodule Account do
use Ecto.Schema

@type t() :: %__MODULE__{}

schema "accounts" do
field :user_id, :integer
has_one :profile, Profile, foreign_key: :user_id
end
end

defmodule Settings do
use Ecto.Schema

@type t() :: %__MODULE__{}

schema "settings" do
field :user_id, :integer
end
end

describe "basic has_one" do
test "generates association type with nil", ctx do
expected_types =
Expand Down Expand Up @@ -186,17 +207,6 @@ defmodule EctoTypedSchema.Types.HasOneTest do
end

describe "through association" do
defmodule Account do
use Ecto.Schema

@type t() :: %__MODULE__{}

schema "accounts" do
field :user_id, :integer
has_one :profile, Profile, foreign_key: :user_id
end
end

test "resolves the target schema through the association chain", ctx do
expected_types =
with_tmpmodule Schema, ctx do
Expand Down Expand Up @@ -234,16 +244,6 @@ defmodule EctoTypedSchema.Types.HasOneTest do
end

describe "multiple has_one associations" do
defmodule Settings do
use Ecto.Schema

@type t() :: %__MODULE__{}

schema "settings" do
field :user_id, :integer
end
end

test "two has_one to different schemas", ctx do
expected_types =
with_tmpmodule Schema, ctx do
Expand Down
Loading