models: fix exception in api_attributes.
Fixup bug in eacb4d4df when calling `api_attributes` on an object that
doesn't have a policy (its policy inherited from ApplicationPolicy).
This commit is contained in:
@@ -54,7 +54,8 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
|
||||
# XXX deprecated, shouldn't expose this as an instance method.
|
||||
def api_attributes(user: CurrentUser.user)
|
||||
Pundit.policy!([user, nil], self).api_attributes
|
||||
policy = Pundit.policy([user, nil], self) || ApplicationPolicy.new([user, nil], self)
|
||||
policy.api_attributes
|
||||
end
|
||||
|
||||
def html_data_attributes
|
||||
|
||||
@@ -8,6 +8,11 @@ class ArtistUrlsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a json request" do
|
||||
get artist_urls_path, as: :json
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render for a complex search" do
|
||||
@artist = FactoryBot.create(:artist, name: "bkub", url_string: "-http://bkub.com")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user