`LoginRequired` -> `NotAuthorized`
This commit is contained in:
parent
93fcebe6c0
commit
9393374eab
|
@ -34,4 +34,4 @@ en:
|
||||||
|
|
||||||
record_not_found: "Record not found"
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class NotAuthorized < Base
|
||||||
|
def status
|
||||||
|
401
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class UserNotFound < NotFound
|
class UserNotFound < NotFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,9 +57,6 @@ module Errors
|
||||||
class Blocked < Forbidden
|
class Blocked < Forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
class LoginRequired < Forbidden
|
|
||||||
end
|
|
||||||
|
|
||||||
class OtherBlockedSelf < Blocked
|
class OtherBlockedSelf < Blocked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ module UseCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_user
|
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
|
end
|
||||||
|
|
||||||
def increment_asked_count
|
def increment_asked_count
|
||||||
|
|
|
@ -44,6 +44,12 @@ describe UseCase::Question::Create do
|
||||||
end
|
end
|
||||||
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
|
shared_examples "validates content" do
|
||||||
context "content is empty" do
|
context "content is empty" do
|
||||||
let(:content) { "" }
|
let(:content) { "" }
|
||||||
|
@ -186,7 +192,7 @@ describe UseCase::Question::Create do
|
||||||
target_user.update!(privacy_require_user: true)
|
target_user.update!(privacy_require_user: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like "forbidden"
|
it_behaves_like "not authorized"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue