username parsing for fa+ users
This commit is contained in:
@@ -42,7 +42,12 @@ class Domain::Fa::Parser::UserPageHelper < Domain::Fa::Parser::Base
|
||||
elsif PREFIXES.include?(name[0])
|
||||
name[1..]
|
||||
else
|
||||
raise("invalid prefix for name: #{name}")
|
||||
if @elem.css("img.userIcon.faplus-icon")
|
||||
# FA+ users have no prefix
|
||||
name
|
||||
else
|
||||
raise("invalid prefix for name: #{name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -356,11 +356,19 @@ describe Domain::Fa::Parser::Page do
|
||||
]
|
||||
end
|
||||
|
||||
it "works with FA+ users" do
|
||||
parser = get_parser("marzimoo_user_page.html")
|
||||
assert_page_type parser, :probably_user_page?
|
||||
up = parser.user_page
|
||||
assert_equal up.name, "MarziMoo"
|
||||
assert_equal up.registered_since, DateTime.parse("Sep 7, 2018 06:19")
|
||||
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}")
|
||||
page = Domain::Fa::Parser::Page.new(contents, require_logged_in: require_logged_in)
|
||||
assert_equal Domain::Fa::Parser::Page::VERSION_2, page.page_version, "page version mismatch for file #{file}"
|
||||
page
|
||||
parser = Domain::Fa::Parser::Page.new(contents, require_logged_in: require_logged_in)
|
||||
assert_equal Domain::Fa::Parser::Page::VERSION_2, parser.page_version, "parser version mismatch for file #{file}"
|
||||
parser
|
||||
end
|
||||
end
|
||||
|
||||
1364
test/fixtures/files/domain/fa/parser/redux/marzimoo_user_page.html
vendored
Normal file
1364
test/fixtures/files/domain/fa/parser/redux/marzimoo_user_page.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user