users: remove as_admin and as_current methods.
This commit is contained in:
@@ -24,15 +24,6 @@ class CurrentUser
|
|||||||
scoped(user, &block)
|
scoped(user, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.as_admin(&block)
|
|
||||||
if block_given?
|
|
||||||
scoped(::User.admins.first, "127.0.0.1", &block)
|
|
||||||
else
|
|
||||||
self.user = ::User.admins.first
|
|
||||||
self.ip_addr = "127.0.0.1"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.as_system(&block)
|
def self.as_system(&block)
|
||||||
if block_given?
|
if block_given?
|
||||||
scoped(::User.system, "127.0.0.1", &block)
|
scoped(::User.system, "127.0.0.1", &block)
|
||||||
|
|||||||
@@ -680,10 +680,6 @@ class User < ApplicationRecord
|
|||||||
include CountMethods
|
include CountMethods
|
||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def as_current(&block)
|
|
||||||
CurrentUser.as(self, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def hide_favorites?
|
def hide_favorites?
|
||||||
!CurrentUser.is_admin? && enable_private_favorites? && CurrentUser.user.id != id
|
!CurrentUser.is_admin? && enable_private_favorites? && CurrentUser.user.id != id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ else
|
|||||||
user = User.find_by_name("albert")
|
user = User.find_by_name("albert")
|
||||||
end
|
end
|
||||||
|
|
||||||
CurrentUser.as_admin
|
CurrentUser.user = User.admins.first
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
if Upload.count == 0
|
if Upload.count == 0
|
||||||
ENV["SKIP_CLOUDFLARE_CHECK"] = "true"
|
ENV["SKIP_CLOUDFLARE_CHECK"] = "true"
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ module TestHelpers
|
|||||||
CurrentUser.as(@user, &block)
|
CurrentUser.as(@user, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_admin(&block)
|
|
||||||
CurrentUser.as_admin(&block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_pixiv_tokens!
|
def load_pixiv_tokens!
|
||||||
if ENV["DANBOORU_PERSIST_PIXIV_SESSION"] && Cache.get("pixiv-papi-access-token")
|
if ENV["DANBOORU_PERSIST_PIXIV_SESSION"] && Cache.get("pixiv-papi-access-token")
|
||||||
Cache.put("pixiv-papi-access-token", Thread.current[:pixiv_papi_access_token])
|
Cache.put("pixiv-papi-access-token", Thread.current[:pixiv_papi_access_token])
|
||||||
|
|||||||
Reference in New Issue
Block a user