Add Translations

mix phx.gen.live Translations Translation translations \
  lang:string title:string teaser:text content:map \
  date:utc_datetime user_id:references:users \
  public:boolean unauthorized:boolean article_id:references:articles
This commit is contained in:
Thelonius Kort
2022-12-26 18:45:40 +01:00
parent f7f1e1a284
commit f66521dba8
13 changed files with 600 additions and 0 deletions

View File

@ -0,0 +1,71 @@
defmodule Outlook.TranslationsTest do
use Outlook.DataCase
alias Outlook.Translations
describe "translations" do
alias Outlook.Translations.Translation
import Outlook.TranslationsFixtures
@invalid_attrs %{content: nil, date: nil, lang: nil, public: nil, teaser: nil, title: nil, unauthorized: nil}
test "list_translations/0 returns all translations" do
translation = translation_fixture()
assert Translations.list_translations() == [translation]
end
test "get_translation!/1 returns the translation with given id" do
translation = translation_fixture()
assert Translations.get_translation!(translation.id) == translation
end
test "create_translation/1 with valid data creates a translation" do
valid_attrs = %{content: %{}, date: ~U[2022-12-25 17:13:00Z], lang: "some lang", public: true, teaser: "some teaser", title: "some title", unauthorized: true}
assert {:ok, %Translation{} = translation} = Translations.create_translation(valid_attrs)
assert translation.content == %{}
assert translation.date == ~U[2022-12-25 17:13:00Z]
assert translation.lang == "some lang"
assert translation.public == true
assert translation.teaser == "some teaser"
assert translation.title == "some title"
assert translation.unauthorized == true
end
test "create_translation/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Translations.create_translation(@invalid_attrs)
end
test "update_translation/2 with valid data updates the translation" do
translation = translation_fixture()
update_attrs = %{content: %{}, date: ~U[2022-12-26 17:13:00Z], lang: "some updated lang", public: false, teaser: "some updated teaser", title: "some updated title", unauthorized: false}
assert {:ok, %Translation{} = translation} = Translations.update_translation(translation, update_attrs)
assert translation.content == %{}
assert translation.date == ~U[2022-12-26 17:13:00Z]
assert translation.lang == "some updated lang"
assert translation.public == false
assert translation.teaser == "some updated teaser"
assert translation.title == "some updated title"
assert translation.unauthorized == false
end
test "update_translation/2 with invalid data returns error changeset" do
translation = translation_fixture()
assert {:error, %Ecto.Changeset{}} = Translations.update_translation(translation, @invalid_attrs)
assert translation == Translations.get_translation!(translation.id)
end
test "delete_translation/1 deletes the translation" do
translation = translation_fixture()
assert {:ok, %Translation{}} = Translations.delete_translation(translation)
assert_raise Ecto.NoResultsError, fn -> Translations.get_translation!(translation.id) end
end
test "change_translation/1 returns a translation changeset" do
translation = translation_fixture()
assert %Ecto.Changeset{} = Translations.change_translation(translation)
end
end
end