Skip to content

Commit

Permalink
Update gh workflow to reflect otp and elixir versions in use (erlef#387)
Browse files Browse the repository at this point in the history
* Update gh workflow to reflect otp and elixir versions in use

* Remove remaining ~E sigils

* Make credo happy

* fixup flaky tests

* Remove redundant with clause
  • Loading branch information
starbelly authored Mar 9, 2022
1 parent 5dab9a2 commit 7898f95
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
types: [opened, synchronize]

env:
otp-version: '23.1.2'
elixir-version: '1.11.2'
otp-version: '24.2.2'
elixir-version: '1.13.3'
MIX_ENV: test

jobs:
Expand Down
15 changes: 8 additions & 7 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ config :erlef, ErlefWeb.Endpoint,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch",
"--watch-options-stdin",
cd: "assets", env: [{"TAILWIND_MODE", "watch"}]
]
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch",
"--watch-options-stdin",
cd: "assets",
env: [{"TAILWIND_MODE", "watch"}]
]
]

# Watch static and templates for browser reloading.
Expand Down
5 changes: 2 additions & 3 deletions lib/erlef/groups/git_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ defmodule Erlef.Groups.GitReport do
{:ok, state} <- get_token(state),
{:ok, state} <- create_files(state),
{:ok, state} <- create_commit(state),
{:ok, state} <- update_branch(state),
{:ok, state} <- get_pr(state) do
{:ok, state}
{:ok, state} <- update_branch(state) do
get_pr(state)
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/erlef/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ defmodule Erlef.HTTP do
defp safe_header_value(v) do
v
|> String.split(" ")
|> Enum.map(&URI.encode/1)
|> Enum.join(" ")
|> Enum.map_join(" ", &URI.encode/1)
end

defp content_type(headers) do
Expand Down
2 changes: 1 addition & 1 deletion lib/erlef/stipend_mail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Erlef.StipendMail do

use Phoenix.Swoosh, view: ErlefWeb.EmailView, layout: {ErlefWeb.LayoutView, :email}

@spec submission(%Erlef.StipendProposal{}) :: %Swoosh.Email{}
@spec submission(Erlef.StipendProposal.t()) :: Swoosh.Email.t()
def submission(proposal) do
dt_str = DateTime.utc_now() |> DateTime.truncate(:second)

Expand Down
3 changes: 0 additions & 3 deletions lib/erlef_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ defmodule ErlefWeb do
def live_view do
quote do
use Phoenix.LiveView,
# TODO fix
# layout: {ErlefWeb.LayoutView, "live.html"}

unquote(view_helpers())
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/erlef_web/html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ defmodule ErlefWeb.HTML do

def calendar(ics_url) do
assigns = %{ics_url: ics_url}

~H"""
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
Expand Down
4 changes: 1 addition & 3 deletions lib/erlef_web/plugs/authz.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ defmodule ErlefWeb.Plug.Authz do
msg = "The resource you requested requires that you are logged in."
link = "https://members.erlef.org/join-us"

"<h3 class='text-center'>#{msg}</h3><p class='text-center'>Don't have a login? <a href='#{
link
}'>Join us!</a></p>"
"<h3 class='text-center'>#{msg}</h3><p class='text-center'>Don't have a login? <a href='#{link}'>Join us!</a></p>"
end
end
8 changes: 7 additions & 1 deletion lib/erlef_web/views/admin/dashboard_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ defmodule ErlefWeb.Admin.DashboardView do
def title(_), do: "Dashboard"

def small_info_box(title, about, icon, link, box_type \\ "info") do
assigns = %{box_type: "small-box bg-" <> box_type, link: link, icon: "fas " <> icon, about: about, title: title}
assigns = %{
box_type: "small-box bg-" <> box_type,
link: link,
icon: "fas " <> icon,
about: about,
title: title
}

~H"""
<div class="col-lg-3 col-6">
Expand Down
1 change: 1 addition & 0 deletions lib/erlef_web/views/admin/layout_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule ErlefWeb.Admin.LayoutView do

icon = Keyword.get(params, :icon, "")
assigns = %{icon: "fas " <> icon}

~H"""
<li class="nav-item">
<%= link(p) do %>
Expand Down
2 changes: 2 additions & 0 deletions lib/erlef_web/views/blog_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ defmodule ErlefWeb.BlogView do

def posted_in(%{category: cat}, nil) when cat in ["eef", "newsletter"] do
assigns = %{}

~H"""
Posted in <a href="/news">News</a>
"""
end

def posted_in(post, wg) do
assigns = %{post_wg: "/wg/" <> post.category, wg: wg}

~H"""
Posted in <a href={@post_wg}><%= @wg.name %></a>
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/erlef_web/views/page_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule ErlefWeb.PageView do

def community_card_wall(items) do
assigns = %{items: items}

~H"""
<div class="row">
<%= for i <- @items do %>
Expand Down
10 changes: 6 additions & 4 deletions lib/erlef_web/views/post_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ defmodule ErlefWeb.PostView do
use ErlefWeb, :view

def posted_in(%{category: cat}, nil) when cat in ["eef", "newsletter"] do
~E"""
"""
Posted in <a href="/news">News</a>
"""
end

def posted_in(post, wg) do
~E"""
Posted in <a href="/wg/<%= post.category %>"><%= wg.name %></a>
def posted_in(%{category: cat} = _post, wg) do
assigns = %{cat_path: "/wg/#{cat}", wg: wg}

~H"""
Posted in <a href={@cat_path}><%= wg.name %></a>
"""
end

Expand Down
2 changes: 1 addition & 1 deletion test/erlef_web/controllers/admin/app_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule ErlefWeb.Admin.AppTest do
test "renders errors when data is invalid", %{conn: conn, app: app} do
conn = put(conn, Routes.admin_app_path(conn, :update, app.slug), app: @invalid_attrs)

assert html_response(conn, 200) =~ "App #{app.name}"
assert html_response(conn, 200) =~ app.name
end
end

Expand Down
8 changes: 5 additions & 3 deletions test/erlef_web/controllers/admin/sponsor_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule ErlefWeb.Admin.SponsorControllerTest do
assert redirected_to(conn) == Routes.admin_sponsor_path(conn, :show, id)

conn = get(conn, Routes.admin_sponsor_path(conn, :show, id))
assert html_response(conn, 200) =~ "Sponsor -"
assert html_response(conn, 200) =~ "Sponsor created successfully"
end

test "renders errors when data is invalid", %{conn: conn} do
Expand All @@ -68,7 +68,7 @@ defmodule ErlefWeb.Admin.SponsorControllerTest do

test "renders form for editing chosen sponsor", %{conn: conn, sponsor: sponsor} do
conn = get(conn, Routes.admin_sponsor_path(conn, :edit, sponsor))
assert html_response(conn, 200) =~ "Sponsor - #{sponsor.name}"
assert html_response(conn, 200) =~ sponsor.name
end
end

Expand All @@ -85,7 +85,9 @@ defmodule ErlefWeb.Admin.SponsorControllerTest do

test "renders errors when data is invalid", %{conn: conn, sponsor: sponsor} do
conn = put(conn, Routes.admin_sponsor_path(conn, :update, sponsor), sponsor: @invalid_attrs)
assert html_response(conn, 200) =~ "Sponsor - #{sponsor.name}"

assert html_response(conn, 200) =~
"Oops, something went wrong! Please check the errors below."
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule ErlefWeb.Admin.WorkingGroupControllerTest do
working_group: @invalid_attrs
)

assert html_response(conn, 200) =~ working_group.name
assert html_response(conn, 200) =~ "123"
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/erlef_web/views/page_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ defmodule ErlefWeb.PageViewTest do

test "community_card_wall/1" do
items = [%{icon: nil, logo: "logo", name: "name", about: "about", link: "link"}]
assert {:safe, _html} = PageView.community_card_wall(items)
assert %Phoenix.LiveView.Rendered{} = PageView.community_card_wall(items)

items = [%{icon: "icon", logo: nil, name: "name", about: "about", link: "link"}]
assert {:safe, _html} = PageView.community_card_wall(items)
assert %Phoenix.LiveView.Rendered{} = PageView.community_card_wall(items)

items = [%{icon: nil, logo: nil, name: "name", about: "about", link: "link"}]
assert {:safe, _html} = PageView.community_card_wall(items)
assert %Phoenix.LiveView.Rendered{} = PageView.community_card_wall(items)
end

test "fellows_card_wall/1" do
fellows = [%{name: "name", avatar: "avatar", about: "about"}]
assert {:safe, _html} = PageView.fellows_card_wall(fellows)
assert %Phoenix.LiveView.Rendered{} = PageView.fellows_card_wall(fellows)
end
end

0 comments on commit 7898f95

Please sign in to comment.