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"
|
||||
|
||||
Reference in New Issue
Block a user