未验证 提交 580eefe1 编写于 作者: M Muhammad Usman 提交者: GitHub

Fix AR signed IDs for STI models

Closes #40187.
上级 812a2c1d
...@@ -90,7 +90,7 @@ def signed_id_verifier=(verifier) ...@@ -90,7 +90,7 @@ def signed_id_verifier=(verifier)
# :nodoc: # :nodoc:
def combine_signed_id_purposes(purpose) def combine_signed_id_purposes(purpose)
[ name.underscore, purpose.to_s ].compact_blank.join("/") [ base_class.name.underscore, purpose.to_s ].compact_blank.join("/")
end end
end end
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
ActiveRecord::Base.signed_id_verifier_secret = SIGNED_ID_VERIFIER_TEST_SECRET ActiveRecord::Base.signed_id_verifier_secret = SIGNED_ID_VERIFIER_TEST_SECRET
class SignedIdTest < ActiveRecord::TestCase class SignedIdTest < ActiveRecord::TestCase
fixtures :accounts, :toys fixtures :accounts, :toys, :companies
setup do setup do
@account = Account.first @account = Account.first
...@@ -26,6 +26,10 @@ class SignedIdTest < ActiveRecord::TestCase ...@@ -26,6 +26,10 @@ class SignedIdTest < ActiveRecord::TestCase
assert_equal @toy, Toy.find_signed(@toy.signed_id) assert_equal @toy, Toy.find_signed(@toy.signed_id)
end end
test "find signed record for single table inheritance (STI Models)" do
assert_equal Company.first, Company.find_signed(Company.first.signed_id)
end
test "raise UnknownPrimaryKey when model have no primary key" do test "raise UnknownPrimaryKey when model have no primary key" do
error = assert_raises(ActiveRecord::UnknownPrimaryKey) do error = assert_raises(ActiveRecord::UnknownPrimaryKey) do
Matey.find_signed("this will not be even verified") Matey.find_signed("this will not be even verified")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册