TEST: TopicViewItem ip logging test

This commit is contained in:
riking 2018-05-21 18:02:15 -07:00 committed by Sam
parent 94f70c7b5c
commit 13a5e41fca
1 changed files with 10 additions and 0 deletions

View File

@ -27,4 +27,14 @@ describe TopicViewItem do
expect(user.user_stat.topics_entered).to eq(1)
end
it "does not log IP address for logged-in users" do
topic = Fabricate(:topic)
user = Fabricate(:user)
add(topic.id, "1.1.1.1", user.id)
expect(TopicViewItem.find_by(topic_id: topic.id, user_id: user.id).ip_address).to eq(nil)
add(topic.id, "1.2.3.4", nil)
expect(TopicViewItem.find_by(topic_id: topic.id, user_id: nil).ip_address).to eq("1.2.3.4")
end
end