diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 24ec27a76..ee9fa44a0 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -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 diff --git a/test/functional/artist_urls_controller_test.rb b/test/functional/artist_urls_controller_test.rb index dc009fb79..8a0f15707 100644 --- a/test/functional/artist_urls_controller_test.rb +++ b/test/functional/artist_urls_controller_test.rb @@ -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")