Remove CurrentUser.ip_addr.
Remove the `CurrentUser.ip_addr` global variable and replace it with `request.remote_ip`. Before we had to track the current user's IP in a global variable so that when we edited a post for example, we could pass down the user's IP to the model and save it in the post_versions table. Now that we now longer save IPs in version tables, we don't need a global variable to get access to the current user's IP outside of controllers.
This commit is contained in:
@@ -28,18 +28,15 @@ class ApplicationRecordTest < ActiveSupport::TestCase
|
||||
@user1 = create(:user)
|
||||
@user2 = create(:user)
|
||||
|
||||
CurrentUser.scoped(@user1, "1.1.1.1") do
|
||||
CurrentUser.scoped(@user1) do
|
||||
Tag.parallel_each do |tag|
|
||||
assert_equal(@user1, CurrentUser.user)
|
||||
assert_equal("1.1.1.1", CurrentUser.ip_addr)
|
||||
|
||||
CurrentUser.scoped(@user2, "2.2.2.2") do
|
||||
CurrentUser.scoped(@user2) do
|
||||
assert_equal(@user2, CurrentUser.user)
|
||||
assert_equal("2.2.2.2", CurrentUser.ip_addr)
|
||||
end
|
||||
|
||||
assert_equal(@user1, CurrentUser.user)
|
||||
assert_equal("1.1.1.1", CurrentUser.ip_addr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user