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:
@@ -4,13 +4,11 @@ class CommentVotesControllerTest < ActionDispatch::IntegrationTest
|
||||
context "A comment votes controller" do
|
||||
setup do
|
||||
CurrentUser.user = @user = create(:user, name: "cirno")
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@comment = create(:comment, creator: @user)
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
|
||||
@@ -8,12 +8,10 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
|
||||
@post = create(:post, id: 100)
|
||||
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
|
||||
@@ -10,7 +10,6 @@ class DmailsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "new action" do
|
||||
|
||||
@@ -243,12 +243,10 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "with a pool: search" do
|
||||
setup do
|
||||
CurrentUser.user = create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "render for a pool: search" do
|
||||
@@ -278,12 +276,10 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "with a favgroup: search" do
|
||||
setup do
|
||||
CurrentUser.user = create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "render for a favgroup: search" do
|
||||
|
||||
Reference in New Issue
Block a user