Skip to content

Commit

Permalink
Add regression test for #45722
Browse files Browse the repository at this point in the history
Adds a test for #45722
  • Loading branch information
ghiculescu committed Sep 12, 2023
1 parent b67bdfb commit b37748f
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -30,14 +30,21 @@ class ActiveRecord::Encryption::ExtendedDeterministicQueriesTest < ActiveRecord:
assert EncryptedBook.find_by("name" => "Dune")
end

test "find_or_create works" do
test "find_or_create_by works" do
EncryptedBook.find_or_create_by!(name: "Dune")
assert EncryptedBook.find_by(name: "Dune")

EncryptedBook.find_or_create_by!(name: "Dune")
assert EncryptedBook.find_by(name: "Dune")
end

test "does not mutate arguments" do
props = { name: "Dune" }

assert_equal "Dune", EncryptedBook.find_or_initialize_by(props).name
assert_equal "Dune", props[:name]
end

test "where(...).first_or_create works" do
EncryptedBook.where(name: "Dune").first_or_create
assert EncryptedBook.exists?(name: "Dune")
Expand Down

0 comments on commit b37748f

Please sign in to comment.