-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from azevedoguigo/development
v0.4.0
- Loading branch information
Showing
7 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule GeckoApi.Tasks.GetAll do | ||
@moduledoc """ | ||
Provides a function call/1 to get all tasks. | ||
""" | ||
alias GeckoApi.Repo | ||
alias GeckoApi.Tasks.Task | ||
import Ecto.Query | ||
|
||
def call(user_id) do | ||
from(t in Task, where: t.user_id == ^user_id) | ||
|> Repo.all() | ||
end | ||
end |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule GeckoApi.Tasks.GetAllTest do | ||
use GeckoApi.DataCase | ||
|
||
alias GeckoApi.{Users, Tasks} | ||
|
||
describe "call/1" do | ||
test "Returns a list of user tasks." do | ||
user_params = %{ | ||
name: "Lewis Hamilton", | ||
email: "[email protected]", | ||
password: "lewisinferrari" | ||
} | ||
{:ok, user} = Users.create_user(user_params) | ||
|
||
task_params = %{ | ||
title: "Create tests of of tasks feature.", | ||
description: "The tests includes all modules and controllers.", | ||
user_id: user.id | ||
} | ||
{:ok, _result} = Tasks.create_task(task_params) | ||
|
||
task_list = Tasks.GetAll.call(user.id) | ||
|
||
assert length(task_list) > 0 | ||
end | ||
end | ||
end |
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