allow empty favs list

This commit is contained in:
Dylan Knutson
2023-08-25 17:05:16 -07:00
parent fea167459d
commit 0a980259dc
3 changed files with 904 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ class Domain::Fa::Parser::UserPageHelper < Domain::Fa::Parser::Base
/\/view\/(\d+)/.match(href)[1]&.to_i || raise(
"invalid url: #{href}"
)
end
end || []
else unimplemented_version!
end
end

View File

@@ -364,6 +364,17 @@ describe Domain::Fa::Parser::Page do
assert_equal up.registered_since, DateTime.parse("Sep 7, 2018 06:19")
end
it "handles pages with no favorites" do
parser = get_parser("azurathefox_user_page.html")
assert_page_type parser, :probably_user_page?
up = parser.user_page
assert_equal up.name, "AzuraTheFox"
assert_equal up.recent_fav_fa_ids, []
assert_equal up.recent_watchers.first.to_a, ["SN214549", "sn214549"]
assert_equal up.recent_watchers.last.to_a, ["Duckyou7464", "duckyou7464"]
assert_equal up.recent_watching, []
end
def get_parser(file, require_logged_in: true)
path = File.join("domain/fa/parser/redux", file)
contents = SpecUtil.read_fixture_file(path) || raise("Couldn't open #{path}")

File diff suppressed because one or more lines are too long