Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Jul 7, 2024
1 parent ada61fa commit dee799e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions test/let_me/policy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,23 @@ defmodule LetMe.PolicyTest do
Policy.filter_allowed_actions(rules, %{id: 2}, object)

assert [%Rule{name: :article_create}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :writer},
object
Enum.sort_by(
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :writer},
object
),
& &1.name
)

assert [%Rule{name: :article_create}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :admin},
object
Enum.sort_by(
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :admin},
object
),
& &1.name
)

assert [
Expand All @@ -284,10 +290,13 @@ defmodule LetMe.PolicyTest do
%{id: 1, role: :admin},
object
)
|> Enum.sort()
|> Enum.sort_by(& &1.name)

assert [%Rule{name: :article_update}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(rules, %{id: 1}, object)
Enum.sort_by(
Policy.filter_allowed_actions(rules, %{id: 1}, object),
& &1.name
)
end

test "can filter by passing the struct only" do
Expand Down

0 comments on commit dee799e

Please sign in to comment.