fix unit tests
This commit is contained in:
@@ -4,7 +4,7 @@ class BulkRevert
|
||||
|
||||
class ConstraintTooGeneralError < Exception ; end
|
||||
|
||||
def process(creator, constraints)
|
||||
def process(creator, constraints = {})
|
||||
@constraints = constraints
|
||||
|
||||
ModAction.log("Processed bulk revert for #{constraints.inspect} by #{creator.name}")
|
||||
@@ -19,6 +19,7 @@ class BulkRevert
|
||||
end
|
||||
|
||||
def initialize
|
||||
@constraints = {}
|
||||
end
|
||||
|
||||
def preview
|
||||
|
||||
@@ -12,12 +12,32 @@ class PawooApiClient
|
||||
end
|
||||
|
||||
def initialize(json)
|
||||
@json = get
|
||||
@json = json
|
||||
end
|
||||
|
||||
def profile_url
|
||||
json["url"]
|
||||
end
|
||||
|
||||
def account_name
|
||||
json["username"]
|
||||
end
|
||||
|
||||
def image_url
|
||||
nil
|
||||
end
|
||||
|
||||
def image_urls
|
||||
[]
|
||||
end
|
||||
|
||||
def tags
|
||||
[]
|
||||
end
|
||||
|
||||
def commentary
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
class Status
|
||||
@@ -32,7 +52,7 @@ class PawooApiClient
|
||||
@json = json
|
||||
end
|
||||
|
||||
def account_profile_url
|
||||
def profile_url
|
||||
json["account"]["url"]
|
||||
end
|
||||
|
||||
@@ -60,9 +80,11 @@ class PawooApiClient
|
||||
end
|
||||
end
|
||||
|
||||
def get_status(url)
|
||||
def get(url)
|
||||
if id = Status.is_match?(url)
|
||||
Status.new(JSON.parse(access_token.get("/api/v1/statuses/#{id}").body))
|
||||
elsif id = Account.is_match?(url)
|
||||
Account.new(JSON.parse(access_token.get("/api/v1/accounts/#{id}").body))
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ module Sources::Strategies
|
||||
attr_reader :image_urls
|
||||
|
||||
def self.url_match?(url)
|
||||
PawooApiClient::Status.is_match?(url)
|
||||
PawooApiClient::Status.is_match?(url) || PawooApiClient::Account.is_match?(url)
|
||||
end
|
||||
|
||||
def referer_url
|
||||
@@ -28,13 +28,13 @@ module Sources::Strategies
|
||||
end
|
||||
|
||||
def api_response
|
||||
@response ||= PawooApiClient.new.get_status(normalized_url)
|
||||
@response ||= PawooApiClient.new.get(normalized_url)
|
||||
end
|
||||
|
||||
def get
|
||||
response = api_response
|
||||
@artist_name = response.account_name
|
||||
@profile_url = response.account_profile_url
|
||||
@profile_url = response.profile_url
|
||||
@image_url = response.image_urls.first
|
||||
@image_urls = response.image_urls
|
||||
@tags = response.tags
|
||||
@@ -54,6 +54,11 @@ module Sources::Strategies
|
||||
true
|
||||
end
|
||||
|
||||
def normalize_for_artist_finder!
|
||||
get
|
||||
@profile_url
|
||||
end
|
||||
|
||||
def dtext_artist_commentary_desc
|
||||
DText.from_html(artist_commentary_desc) do |element|
|
||||
if element.name == "a"
|
||||
|
||||
@@ -173,6 +173,7 @@ class FavoriteGroup < ApplicationRecord
|
||||
end
|
||||
|
||||
def add!(post_id)
|
||||
post_id = post_id.id if post_id.is_a?(Post)
|
||||
return if contains?(post_id)
|
||||
|
||||
clear_post_id_array
|
||||
@@ -180,12 +181,14 @@ class FavoriteGroup < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.purge_post(post_id)
|
||||
post_id = post_id.id if post_id.is_a?(Post)
|
||||
for_post(post_id).find_each do |group|
|
||||
group.remove!(post_id)
|
||||
end
|
||||
end
|
||||
|
||||
def remove!(post_id)
|
||||
post_id = post_id.id if post_id.is_a?(Post)
|
||||
return unless contains?(post_id)
|
||||
|
||||
clear_post_id_array
|
||||
|
||||
@@ -13,7 +13,7 @@ class PostDisapproval < ApplicationRecord
|
||||
scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])}
|
||||
|
||||
def self.prune!
|
||||
PostDisapproval.where("post_id in (select _.post_id from post_disapprovals _ where _.created_at < ?)", DELETION_THRESHOLD.ago)
|
||||
PostDisapproval.where("post_id in (select _.post_id from post_disapprovals _ where _.created_at < ?)", DELETION_THRESHOLD.ago).delete_all
|
||||
end
|
||||
|
||||
def self.dmail_messages!
|
||||
|
||||
Reference in New Issue
Block a user