`LoginRequired` -> `NotAuthorized`
This commit is contained in:
parent
93fcebe6c0
commit
9393374eab
|
@ -34,4 +34,4 @@ en:
|
|||
|
||||
record_not_found: "Record not found"
|
||||
|
||||
login_required: "You need to be logged in to perform this action"
|
||||
not_authorized: "You need to be logged in to perform this action"
|
||||
|
|
|
@ -44,6 +44,12 @@ module Errors
|
|||
end
|
||||
end
|
||||
|
||||
class NotAuthorized < Base
|
||||
def status
|
||||
401
|
||||
end
|
||||
end
|
||||
|
||||
class UserNotFound < NotFound
|
||||
end
|
||||
|
||||
|
@ -51,9 +57,6 @@ module Errors
|
|||
class Blocked < Forbidden
|
||||
end
|
||||
|
||||
class LoginRequired < Forbidden
|
||||
end
|
||||
|
||||
class OtherBlockedSelf < Blocked
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ module UseCase
|
|||
end
|
||||
|
||||
def check_user
|
||||
raise Errors::LoginRequired if target_user.privacy_require_user && !source_user_id
|
||||
raise Errors::NotAuthorized if target_user.privacy_require_user && !source_user_id
|
||||
end
|
||||
|
||||
def increment_asked_count
|
||||
|
|
|
@ -44,6 +44,12 @@ describe UseCase::Question::Create do
|
|||
end
|
||||
end
|
||||
|
||||
shared_examples "not authorized" do
|
||||
it "raises an error" do
|
||||
expect { subject }.to raise_error(Errors::NotAuthorized)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples "validates content" do
|
||||
context "content is empty" do
|
||||
let(:content) { "" }
|
||||
|
@ -186,7 +192,7 @@ describe UseCase::Question::Create do
|
|||
target_user.update!(privacy_require_user: true)
|
||||
end
|
||||
|
||||
it_behaves_like "forbidden"
|
||||
it_behaves_like "not authorized"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue