Skip to content

Commit

Permalink
Updates repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Apr 4, 2018
1 parent b787555 commit 3a302e8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/repositories/updates_repository_test.exs
@@ -0,0 +1,25 @@
defmodule WeatherStationManager.UpdatesRepositoryTest do
use WeatherStationManager.ModelCase

alias WeatherStationManager.{ Repo, Update, UpdatesRepository }

@update %{
:lat => 42.0,
:lon => 23.0,
:spam => "eggs",
:temperature => 100.0,
:station => "South Yarra"
}

test "save new content in the DB" do
UpdatesRepository.save(@update)

assert (length Repo.all Update) == 1
end

test "assigns an ID to the record" do
{ :ok, record } = UpdatesRepository.save(@update)

refute record.id == nil
end
end
8 changes: 8 additions & 0 deletions web/repositories/updates_repository.ex
@@ -0,0 +1,8 @@
defmodule WeatherStationManager.UpdatesRepository do
alias WeatherStationManager.{ Repo, Update }

def save(update) do
Update.changeset(%Update{}, update)
|> Repo.insert
end
end

0 comments on commit 3a302e8

Please sign in to comment.