5 Commits

  1. 15
      CHANGELOG.md
  2. 1213
      assets/package-lock.json
  3. 6
      assets/package.json
  4. 2
      lib/mirage/notes/note.ex
  5. 4
      lib/mirage_web/live/note_live/index.ex
  6. 2
      mix.exs
  7. 4
      mix.lock
  8. 2
      test/mirage/links_test.exs
  9. 65
      test/mirage/notes_test.exs
  10. 63
      test/mirage/topics_test.exs
  11. 91
      test/mirage_web/controllers/note_controller_test.exs
  12. 6
      test/mirage_web/controllers/topic_controller_test.exs
  13. 14
      test/mirage_web/controllers/user_settings_controller_test.exs
  14. 6
      test/mirage_web/live/link_live_test.exs

15
CHANGELOG.md

@ -5,6 +5,21 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.63.0](https://git.inhji.de/inhji/mirage/compare/v0.62.0...v0.63.0) (2021-03-05)
### Chores:
* update deps
* remove list_notes
### Features:
* update codemirror
## [v0.62.0](https://git.inhji.de/inhji/mirage/compare/v0.61.0...v0.62.0) (2021-02-27)

1213
assets/package-lock.json
File diff suppressed because it is too large
View File

6
assets/package.json

@ -5,9 +5,9 @@
"watch": "webpack --mode development --watch"
},
"dependencies": {
"@codemirror/basic-setup": "^0.17.1",
"@codemirror/lang-markdown": "^0.17.2",
"@codemirror/theme-one-dark": "^0.17.5",
"@codemirror/basic-setup": "^0.18",
"@codemirror/lang-markdown": "^0.18",
"@codemirror/theme-one-dark": "^0.18",
"@yaireo/tagify": "^3.22.3",
"minireset.css": "^0.0.7",
"nprogress": "^0.2.0",

2
lib/mirage/notes/note.ex

@ -6,7 +6,7 @@ defmodule Mirage.Notes.Note do
field :title, :string
field :content, :string
field :content_html, :string
field :views, :integer
field :views, :integer, default: 0
field :viewed_at, :naive_datetime
many_to_many :links, Mirage.Links.Link, join_through: "notes_links"

4
lib/mirage_web/live/note_live/index.ex

@ -40,8 +40,4 @@ defmodule MirageWeb.NoteLive.Index do
|> assign(:page_title, "Listing Notes")
|> assign(:note, nil)
end
defp list_notes do
Notes.list_notes()
end
end

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.62.0"
@version "0.63.0"
def project do
[

4
mix.lock

@ -55,8 +55,8 @@
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.0", "da9d49ee7e6bb1c259d36ce6539cd45ae14d81247a2b0c90edf55e2b50507f7b", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5cfe67ad464b243835512aa44321cee91faed6ea868d7fb761d7016e02915c3d"},
"telemetry_poller": {:hex, :telemetry_poller, "0.5.1", "21071cc2e536810bac5628b935521ff3e28f0303e770951158c73eaaa01e962a", [:rebar3], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4cab72069210bc6e7a080cec9afffad1b33370149ed5d379b81c7c5f0c663fd4"},
"timex": {:hex, :timex, "3.6.3", "58ce6c9eda8ed47fc80c24dde09d481465838d3bcfc230949287fc1b0b0041c1", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "6d69f4f95fcf5684102a9cb3cf92c5ba6545bd60ed8d8a6a93cd2a4a4fb0d9ec"},
"tzdata": {:hex, :tzdata, "1.0.5", "69f1ee029a49afa04ad77801febaf69385f3d3e3d1e4b56b9469025677b89a28", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "55519aa2a99e5d2095c1e61cc74c9be69688f8ab75c27da724eb8279ff402a5a"},
"timex": {:hex, :timex, "3.6.4", "137a49450b8d1f80efff82de4b78ab9ad2e367f06346825704310599733f338b", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "f6fce3f07ab67f525043af5b1f68ed5fa12a41b9dab95a9a98bb6acfb30ecadc"},
"tzdata": {:hex, :tzdata, "1.1.0", "72f5babaa9390d0f131465c8702fa76da0919e37ba32baa90d93c583301a8359", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "18f453739b48d3dc5bcf0e8906d2dc112bb40baafe2c707596d89f3c8dd14034"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"x509": {:hex, :x509, "0.8.2", "27b11ae9637dc5cfea18e6547c4c5a0fce8af024851260223d00fe0755dcf372", [:mix], [], "hexpm", "36b92a8305d034b6e1819b61890676beaba221692065e30611d0c92e8a978c7c"},
}

2
test/mirage/links_test.exs

@ -15,7 +15,7 @@ defmodule Mirage.LinksTest do
@invalid_attrs %{title: nil, url: nil}
test "list_notes_links/0 returns all notes_links" do
link = link_fixture()
link = link_fixture() |> Links.preload_link()
assert Links.list_links() == [link]
end

65
test/mirage/notes_test.exs

@ -2,10 +2,10 @@ defmodule Mirage.NotesTest do
use Mirage.DataCase
alias Mirage.Notes
alias Mirage.Notes.Note
alias Mirage.Tags
describe "notes" do
alias Mirage.Notes.Note
@valid_attrs %{content: "some content", title: "some title"}
@at_attrs %{content: "some content", title: "@home"}
@update_attrs %{content: "some updated content"}
@ -40,7 +40,7 @@ defmodule Mirage.NotesTest do
test "list_notes/1 with param :untagged returns all untagged notes" do
note = note_fixture(@valid_attrs)
assert Notes.list_notes(:untagged) == [note]
Notes.Tags.update_tags(note, "foo,bar")
Tags.update_tags(note, "foo,bar")
assert Notes.list_notes(:untagged) == []
end
@ -136,63 +136,4 @@ defmodule Mirage.NotesTest do
assert %Ecto.Changeset{} = Notes.change_note(note)
end
end
describe "topics" do
alias Mirage.Notes.Topic
@valid_attrs %{text: "some text"}
@update_attrs %{text: "some updated text"}
@invalid_attrs %{text: nil}
def topic_fixture(attrs \\ %{}) do
{:ok, topic} =
attrs
|> Enum.into(@valid_attrs)
|> Notes.create_topic()
topic
end
test "list_topics/0 returns all topics" do
topic = topic_fixture() |> Notes.preload_topic()
assert Notes.list_topics() == [topic]
end
test "get_topic!/1 returns the topic with given id" do
topic = topic_fixture()
assert Notes.get_topic!(topic.id) == topic
end
test "create_topic/1 with valid data creates a topic" do
assert {:ok, %Topic{} = topic} = Notes.create_topic(@valid_attrs)
assert topic.text == "some text"
end
test "create_topic/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Notes.create_topic(@invalid_attrs)
end
test "update_topic/2 with valid data updates the topic" do
topic = topic_fixture()
assert {:ok, topic} = Notes.update_topic(topic, @update_attrs)
assert topic.text == "some updated text"
end
test "update_topic/2 with invalid data returns error changeset" do
topic = topic_fixture()
assert {:error, %Ecto.Changeset{}} = Notes.update_topic(topic, @invalid_attrs)
assert topic == Notes.get_topic!(topic.id)
end
test "delete_topic/1 deletes the topic" do
topic = topic_fixture()
assert {:ok, %Topic{}} = Notes.delete_topic(topic)
assert_raise Ecto.NoResultsError, fn -> Notes.get_topic!(topic.id) end
end
test "change_topic/1 returns a topic changeset" do
topic = topic_fixture()
assert %Ecto.Changeset{} = Notes.change_topic(topic)
end
end
end

63
test/mirage/topics_test.exs

@ -0,0 +1,63 @@
defmodule Mirage.TopicsTest do
use Mirage.DataCase
alias Mirage.Topics
alias Mirage.Topics.Topic
describe "topics" do
@valid_attrs %{text: "some text"}
@update_attrs %{text: "some updated text"}
@invalid_attrs %{text: nil}
def topic_fixture(attrs \\ %{}) do
{:ok, topic} =
attrs
|> Enum.into(@valid_attrs)
|> Topics.create_topic()
topic
end
test "list_topics/0 returns all topics" do
topic = topic_fixture() |> Topics.preload_topic()
assert Topics.list_topics() == [topic]
end
test "get_topic!/1 returns the topic with given id" do
topic = topic_fixture()
assert Topics.get_topic!(topic.id) == topic
end
test "create_topic/1 with valid data creates a topic" do
assert {:ok, %Topic{} = topic} = Topics.create_topic(@valid_attrs)
assert topic.text == "some text"
end
test "create_topic/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Topics.create_topic(@invalid_attrs)
end
test "update_topic/2 with valid data updates the topic" do
topic = topic_fixture()
assert {:ok, topic} = Topics.update_topic(topic, @update_attrs)
assert topic.text == "some updated text"
end
test "update_topic/2 with invalid data returns error changeset" do
topic = topic_fixture()
assert {:error, %Ecto.Changeset{}} = Topics.update_topic(topic, @invalid_attrs)
assert topic == Topics.get_topic!(topic.id)
end
test "delete_topic/1 deletes the topic" do
topic = topic_fixture()
assert {:ok, %Topic{}} = Topics.delete_topic(topic)
assert_raise Ecto.NoResultsError, fn -> Topics.get_topic!(topic.id) end
end
test "change_topic/1 returns a topic changeset" do
topic = topic_fixture()
assert %Ecto.Changeset{} = Topics.change_topic(topic)
end
end
end

91
test/mirage_web/controllers/note_controller_test.exs

@ -1,91 +0,0 @@
defmodule MirageWeb.NoteControllerTest do
use MirageWeb.ConnCase
import Mirage.NoteFixtures
setup :register_and_log_in_user
@create_attrs %{content: "some content", title: "some title", topic_string: "some tag"}
@update_attrs %{
content: "some updated content with link [[@NOTE_ID]]",
topic_string: "some other tag"
}
@invalid_attrs %{content: nil}
describe "index" do
test "lists all notes", %{conn: conn} do
conn = get(conn, Routes.note_path(conn, :index))
assert html_response(conn, 200) =~ "Listing Notes"
end
end
describe "new note" do
test "renders form", %{conn: conn} do
conn = get(conn, Routes.note_path(conn, :new))
assert html_response(conn, 200) =~ "New Note"
end
end
describe "create note" do
test "redirects to show when data is valid", %{conn: conn} do
conn = post(conn, Routes.note_path(conn, :create), note: @create_attrs)
assert %{id: id} = redirected_params(conn)
assert redirected_to(conn) == Routes.live_path(conn, MirageWeb.ShowNoteLive, id)
conn = get(conn, Routes.live_path(conn, MirageWeb.ShowNoteLive, id))
assert html_response(conn, 200) =~ "some title"
assert html_response(conn, 200) =~ "some tag"
end
test "renders errors when data is invalid", %{conn: conn} do
conn = post(conn, Routes.note_path(conn, :create), note: @invalid_attrs)
assert html_response(conn, 200) =~ "New Note"
end
end
describe "edit note" do
setup [:create_note]
test "renders form for editing chosen note", %{conn: conn, note: note} do
conn = get(conn, Routes.note_path(conn, :edit, note))
assert html_response(conn, 200) =~ "Edit Note"
end
end
describe "update note" do
setup [:create_note]
test "redirects when data is valid", %{conn: conn, note: note} do
attrs =
Map.update!(@update_attrs, :content, fn content ->
String.replace(content, "@NOTE_ID", to_string(note.id))
end)
conn = put(conn, Routes.note_path(conn, :update, note), note: attrs)
assert redirected_to(conn) == Routes.live_path(conn, MirageWeb.ShowNoteLive, note)
conn = get(conn, Routes.live_path(conn, MirageWeb.ShowNoteLive, note))
assert html_response(conn, 200) =~ "some updated content with link"
assert html_response(conn, 200) =~ "some other tag"
refute html_response(conn, 200) =~ "some tag"
end
test "renders errors when data is invalid", %{conn: conn, note: note} do
conn = put(conn, Routes.note_path(conn, :update, note), note: @invalid_attrs)
assert html_response(conn, 200) =~ "Edit Note"
end
end
describe "delete note" do
setup [:create_note]
test "deletes chosen note", %{conn: conn, note: note} do
conn = delete(conn, Routes.note_path(conn, :delete, note))
assert redirected_to(conn) == Routes.note_path(conn, :index)
assert_error_sent 404, fn ->
get(conn, Routes.live_path(conn, MirageWeb.ShowNoteLive, note))
end
end
end
end

6
test/mirage_web/controllers/topic_controller_test.exs

@ -1,7 +1,7 @@
defmodule MirageWeb.TopicControllerTest do
use MirageWeb.ConnCase
alias Mirage.Notes
alias Mirage.Topics
setup :register_and_log_in_user
@ -10,7 +10,7 @@ defmodule MirageWeb.TopicControllerTest do
@invalid_attrs %{text: nil}
def fixture(:topic) do
{:ok, topic} = Notes.create_topic(@create_attrs)
{:ok, topic} = Topics.create_topic(@create_attrs)
topic
end
@ -36,7 +36,7 @@ defmodule MirageWeb.TopicControllerTest do
assert redirected_to(conn) == Routes.topic_path(conn, :show, id)
conn = get(conn, Routes.topic_path(conn, :show, id))
assert html_response(conn, 200) =~ "Topic some text"
assert html_response(conn, 200) =~ "some text"
end
test "renders errors when data is invalid", %{conn: conn} do

14
test/mirage_web/controllers/user_settings_controller_test.exs

@ -6,11 +6,11 @@ defmodule MirageWeb.UserSettingsControllerTest do
setup :register_and_log_in_user
describe "GET /users/settings" do
describe "GET /users/edit" do
test "renders settings page", %{conn: conn} do
conn = get(conn, Routes.user_settings_path(conn, :edit))
response = html_response(conn, 200)
assert response =~ "<h1>Settings</h1>"
assert response =~ "<h1>Edit User</h1>"
end
test "redirects if user is not logged in" do
@ -20,7 +20,7 @@ defmodule MirageWeb.UserSettingsControllerTest do
end
end
describe "PUT /users/settings (change password form)" do
describe "PUT /users/edit (change password form)" do
test "updates the user password and resets tokens", %{conn: conn, user: user} do
new_password_conn =
put(conn, Routes.user_settings_path(conn, :update), %{
@ -50,7 +50,7 @@ defmodule MirageWeb.UserSettingsControllerTest do
})
response = html_response(old_password_conn, 200)
assert response =~ "<h1>Settings</h1>"
assert response =~ "<h1>Edit User</h1>"
assert response =~ "should be at least 12 character(s)"
assert response =~ "does not match password"
assert response =~ "is not valid"
@ -59,7 +59,7 @@ defmodule MirageWeb.UserSettingsControllerTest do
end
end
describe "PUT /users/settings (change email form)" do
describe "PUT /users/edit (change email form)" do
@tag :capture_log
test "updates the user email", %{conn: conn, user: user} do
conn =
@ -83,13 +83,13 @@ defmodule MirageWeb.UserSettingsControllerTest do
})
response = html_response(conn, 200)
assert response =~ "<h1>Settings</h1>"
assert response =~ "<h1>Edit User</h1>"
assert response =~ "must have the @ sign and no spaces"
assert response =~ "is not valid"
end
end
describe "GET /users/settings/confirm_email/:token" do
describe "GET /users/edit/confirm_email/:token" do
setup %{user: user} do
email = unique_user_email()

6
test/mirage_web/live/link_live_test.exs

@ -22,7 +22,7 @@ defmodule MirageWeb.LinkLiveTest do
{:ok, show_live, _html} = live(conn, Routes.link_show_path(conn, :show, link))
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Note link"
"Edit Link"
assert_patch(show_live, Routes.link_show_path(conn, :edit, link))
@ -47,7 +47,7 @@ defmodule MirageWeb.LinkLiveTest do
test "displays link", %{conn: conn, link: link} do
{:ok, _show_live, html} = live(conn, Routes.link_show_path(conn, :show, link))
assert html =~ "Show Note link"
assert html =~ "Show Link"
assert html =~ link.title
end
@ -55,7 +55,7 @@ defmodule MirageWeb.LinkLiveTest do
{:ok, show_live, _html} = live(conn, Routes.link_show_path(conn, :show, link))
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Note link"
"Edit Link"
assert_patch(show_live, Routes.link_show_path(conn, :edit, link))

Loading…
Cancel
Save