Oops, fix sloppiness about pet service refactor
I guess I like super didn't test this end-to-end, oops!!
This commit is contained in:
parent
abfe1e6df7
commit
7607c2c015
3 changed files with 9 additions and 4 deletions
|
@ -1,13 +1,13 @@
|
|||
class PetsController < ApplicationController
|
||||
rescue_from Pet::PetNotFound, with: :pet_not_found
|
||||
rescue_from Pet::DownloadError, with: :pet_download_error
|
||||
rescue_from Neopets::CustomPets::PetNotFound, with: :pet_not_found
|
||||
rescue_from Neopets::CustomPets::DownloadError, with: :pet_download_error
|
||||
rescue_from Pet::UnexpectedDataFormat, with: :unexpected_data_format
|
||||
|
||||
def load
|
||||
# Uncomment this to temporarily disable modeling for most users.
|
||||
# return modeling_disabled unless user_signed_in? && current_user.admin?
|
||||
|
||||
raise Pet::PetNotFound unless params[:name]
|
||||
raise Neopets::CustomPets::PetNotFound unless params[:name]
|
||||
@pet = Pet.load(params[:name])
|
||||
points = contribute(current_user, @pet)
|
||||
|
||||
|
|
|
@ -114,5 +114,7 @@ class Pet < ApplicationRecord
|
|||
pet.load!(**options)
|
||||
pet
|
||||
end
|
||||
|
||||
class UnexpectedDataFormat < RuntimeError;end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ module Neopets::CustomPets
|
|||
|
||||
private
|
||||
|
||||
# Send an AMFPHP request, re-raising errors as `Pet::DownloadError`.
|
||||
# Send an AMFPHP request, re-raising errors as `DownloadError`.
|
||||
# Return the response body as a `HashWithIndifferentAccess`.
|
||||
def send_amfphp_request(request, timeout: 10)
|
||||
begin
|
||||
|
@ -61,4 +61,7 @@ module Neopets::CustomPets
|
|||
HashWithIndifferentAccess.new(response_data)
|
||||
end
|
||||
end
|
||||
|
||||
class PetNotFound < RuntimeError;end
|
||||
class DownloadError < RuntimeError;end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue