From 256b4d0b9a354c4ba09f17cc6f97ff7fe5a98dd9 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 14 Feb 2024 17:54:28 -0500 Subject: [PATCH] test: add test for filter policy on bulk actions --- mix.exs | 2 +- test/ash_postgres_test.exs | 9 ++++++++- test/filter_field_policy_test.exs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index d3b73f4..19567f1 100644 --- a/mix.exs +++ b/mix.exs @@ -158,7 +158,7 @@ defmodule AshPostgres.MixProject do {:jason, "~> 1.0"}, {:postgrex, ">= 0.0.0"}, {:ash, - ash_version(github: "ash-project/ash", ref: "f23f0a29fec8a231e3fbff64034be8c9efb87e73")}, + ash_version(github: "ash-project/ash", ref: "dcbccec7c36e2cad9d8366fa797b617e043b7b28")}, {:benchee, "~> 1.1", only: [:dev, :test]}, {:git_ops, "~> 2.5", only: [:dev, :test]}, {:ex_doc, github: "elixir-lang/ex_doc", only: [:dev, :test], runtime: false}, diff --git a/test/ash_postgres_test.exs b/test/ash_postgres_test.exs index a0d25ac..736caae 100644 --- a/test/ash_postgres_test.exs +++ b/test/ash_postgres_test.exs @@ -18,8 +18,15 @@ defmodule AshPostgresTest do |> Ash.Changeset.new(%{title: "good"}) |> AshPostgres.Test.Api.create!() + assert_raise Ash.Error.Forbidden, fn -> + post + |> Ash.Changeset.for_update(:update, %{title: "bad"}, authorize?: true) + |> AshPostgres.Test.Api.update!() + |> Map.get(:title) + end + post - |> Ash.Changeset.for_update(:update, %{title: "bad"}, authorize?: true) + |> Ash.Changeset.for_update(:update, %{title: "okay"}, authorize?: true) |> AshPostgres.Test.Api.update!() |> Map.get(:title) end diff --git a/test/filter_field_policy_test.exs b/test/filter_field_policy_test.exs index f292bec..35b29e5 100644 --- a/test/filter_field_policy_test.exs +++ b/test/filter_field_policy_test.exs @@ -1,7 +1,7 @@ defmodule FilterFieldPolicyTest do use AshPostgres.RepoCase, async: false - alias AshPostgres.Test.{Api, Post, Organization, User} + alias AshPostgres.Test.{Api, Organization, Post, User} require Ash.Query