Skip to content

Commit dacc154

Browse files
address comments
1 parent e8cdfca commit dacc154

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

test/pointing_party/vote_calculator_test.exs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,15 @@ defmodule PointingParty.VoteCalculatorTest do
6868

6969
calculated_votes =
7070
Enum.reduce(votes, %{}, fn vote, acc ->
71-
acc
72-
|> Map.get_and_update(vote, &{&1, (&1 || 0) + 1})
73-
|> elem(1)
71+
value = (acc[vote] || 0) + 1
72+
Map.put(acc, vote, value)
7473
end)
7574

7675
sorted =
7776
calculated_votes
78-
|> Enum.sort_by(&elem(&1, 1))
77+
|> Enum.sort_by(fn ({_k, v}) -> v end)
78+
|> Enum.map(fn ({a, _b}) -> a end)
7979
|> Enum.take(2)
80-
|> Enum.map(&elem(&1, 0))
8180

8281
assert sorted == winner
8382
end

test/pointing_party_web/controllers/page_controller_test.exs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ defmodule PointingPartyWeb.PageControllerTest do
55

66
describe "authenticated user" do
77
setup %{conn: conn} do
8-
conn =
9-
conn
10-
|> Plug.Conn.assign(:username, @username)
8+
conn = Plug.Conn.assign(conn, :username, @username)
119

1210
{:ok, %{conn: conn}}
1311
end

0 commit comments

Comments
 (0)