FIX: Admin panel referral stats not counting topics correctly

Due to what seems to be a bug in ActiveRecord, the distinct: true option
is not recognized on counts with string column names. This commit fixes
that by moving the DISTINCT into the count string.

For robustness, the integration spec for IncomingLinksReport was
rewritten to be an actual integration spec, running the actual interface
on actual fake data.
Merge pull request #2999 from riking/fix_top_referrers_topic_count

FIX: Topic referrals by user were wrong