Skip to content

Commit

Permalink
Test find_signed/! on Relation
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanvlviv committed Oct 27, 2020
1 parent 7cb4513 commit aac3d28
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions activerecord/test/cases/signed_id_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class SignedIdTest < ActiveRecord::TestCase
assert_equal @account, Account.find_signed(@account.signed_id)
end

test "find signed record on relation" do
assert_equal @account, Account.where("1=1").find_signed(@account.signed_id)

assert_nil Account.where("1=0").find_signed(@account.signed_id)
end

test "find signed record with custom primary key" do
assert_equal @toy, Toy.find_signed(@toy.signed_id)
end
Expand All @@ -41,6 +47,14 @@ class SignedIdTest < ActiveRecord::TestCase
assert_equal @account, Account.find_signed!(@account.signed_id)
end

test "find signed record with a bang on relation" do
assert_equal @account, Account.where("1=1").find_signed!(@account.signed_id)

assert_raises(ActiveRecord::RecordNotFound) do
Account.where("1=0").find_signed!(@account.signed_id)
end
end

test "fail to find record from broken signed id" do
assert_nil Account.find_signed("this won't find anything")
end
Expand Down

0 comments on commit aac3d28

Please sign in to comment.