Skip to content

Commit

Permalink
FIX: Don't track user profile view when viewed by system user.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Aug 23, 2016
1 parent f192326 commit 17f0727
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/user_profile_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def self.add(user_profile_id, ip, user_id=nil, at=nil, skip_redis=false)
at ||= Time.zone.now
redis_key = "user-profile-view:#{user_profile_id}:#{at.to_date}"
if user_id
return if user_id < 1
redis_key << ":user-#{user_id}"
else
redis_key << ":ip-#{ip}"
Expand Down
5 changes: 5 additions & 0 deletions spec/models/user_profile_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ def add(user_profile_id, ip, user_id=nil, at=nil)
expect(described_class.count).to eq(1)
end
end

it "should not create a profile view for the system user" do
add(user_profile_id, '1.1.1.1', Discourse::SYSTEM_USER_ID)
expect(described_class.count).to eq(0)
end
end

0 comments on commit 17f0727

Please sign in to comment.