Skip to content

test: add failing test for changing_attributes check for create #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vonagam
Copy link
Contributor

@vonagam vonagam commented May 16, 2024

Based on code and previous behavior (before being switched to filter from match) changing_attributes should work with create actions. But currently it does not.

@zachdaniel zachdaniel merged commit 74cead8 into ash-project:main May 16, 2024
39 of 45 checks passed
@vonagam vonagam deleted the test-create-changing-attributes branch May 16, 2024 13:41
@zachdaniel
Copy link
Contributor

Changing the test to

  test "filter policies are applied in create" do
    assert_raise Ash.Error.Forbidden, fn ->
      AshPostgres.Test.Post
      |> Ash.Changeset.for_create(:create, %{title: "worst"}, authorize?: true)
      |> Ash.create!()
    end
  end

makes it pass, so I don't have a reproduction of the issue. However, I did notice that if you were using the :from option in the policy, i.e from: nil, to: "foo" that it would have caused it to appear as false, so I'm going to amend the changing_attributes policy to consider all attributes as going from nil to the value in ash core.

@zachdaniel
Copy link
Contributor

This is because the ash_postgres domain has

  authorization do
    authorize(:when_requested)
  end

@vonagam
Copy link
Contributor Author

vonagam commented May 16, 2024

Ah, missed that. I was having that issue on Ash 2 so assumed that the issue was reproduced on Ash 3 when got the failing test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants