models: stop saving IP addresses in version tables.

Mark various `creator_ip_addr` and `updater_ip_addr` columns as ignored
and stop updating them in preparation for dropping them.
This commit is contained in:
evazion
2022-09-18 03:02:30 -05:00
parent 44d4452068
commit d4da8499ce
28 changed files with 60 additions and 50 deletions

View File

@@ -2,7 +2,6 @@ FactoryBot.define do
factory(:comment) do |f|
creator
post
creator_ip_addr { FFaker::Internet.ip_v4_address }
body {FFaker::Lorem.sentences.join(" ")}
end
end

View File

@@ -3,7 +3,6 @@ FactoryBot.define do
owner factory: :user
from factory: :user
to factory: :user
creator_ip_addr { FFaker::Internet.ip_v4_address }
title {FFaker::Lorem.words.join(" ")}
body {FFaker::Lorem.sentences.join(" ")}
end

View File

@@ -2,7 +2,6 @@ FactoryBot.define do
factory(:post) do
md5 { SecureRandom.hex(32) }
uploader
uploader_ip_addr {"127.0.0.1"}
tag_string {"tag1 tag2"}
tag_count {2}
tag_count_general {2}

View File

@@ -1,7 +1,6 @@
FactoryBot.define do
factory(:upload) do
uploader factory: :user
uploader_ip_addr { "127.0.0.1" }
status { "pending" }
source { "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg" }

View File

@@ -11,7 +11,7 @@ class SearchableTest < ActiveSupport::TestCase
subject { Post }
setup do
@p1 = create(:post, source: "a1", score: 1, is_deleted: true, uploader_ip_addr: "10.0.0.1")
@p1 = create(:post, source: "a1", score: 1, is_deleted: true)
@p2 = create(:post, source: "b2", score: 2, is_deleted: false)
@p3 = create(:post, source: "c3", score: 3, is_deleted: false)
end
@@ -108,11 +108,14 @@ class SearchableTest < ActiveSupport::TestCase
end
context "for an inet attribute" do
subject { UserSession }
should "work" do
assert_search_equals(@p1, uploader_ip_addr: "10.0.0.1")
assert_search_equals(@p1, uploader_ip_addr: "10.0.0.1/24")
assert_search_equals(@p1, uploader_ip_addr: "10.0.0.1,1.1.1.1")
assert_search_equals(@p1, uploader_ip_addr: "10.0.0.1 1.1.1.1")
@us = create(:user_session, ip_addr: "10.0.0.1")
assert_search_equals(@us, ip_addr: "10.0.0.1")
assert_search_equals(@us, ip_addr: "10.0.0.1/24")
assert_search_equals(@us, ip_addr: "10.0.0.1,1.1.1.1")
assert_search_equals(@us, ip_addr: "10.0.0.1 1.1.1.1")
end
end
@@ -258,8 +261,8 @@ class SearchableTest < ActiveSupport::TestCase
should "work" do
@media_asset = create(:media_asset)
@upload1 = create(:upload, media_assets: [@media_asset])
@upload2 = create(:upload, media_assets: [@media_asset])
@upload1 = create(:upload, upload_media_assets: [build(:upload_media_asset, media_asset: @media_asset)])
@upload2 = create(:upload, upload_media_assets: [build(:upload_media_asset, media_asset: @media_asset)])
assert_search_equals([@upload2, @upload1], media_asset: { md5: @media_asset.md5 })
end

View File

@@ -5,7 +5,6 @@ class DmailTest < ActiveSupport::TestCase
setup do
@user = FactoryBot.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "1.2.3.4"
end
teardown do
@@ -80,7 +79,7 @@ class DmailTest < ActiveSupport::TestCase
should "create a copy for each user" do
@new_user = FactoryBot.create(:user)
assert_difference("Dmail.count", 2) do
Dmail.create_split(from: CurrentUser.user, creator_ip_addr: "127.0.0.1", to: @new_user, title: "foo", body: "foo")
Dmail.create_split(from: CurrentUser.user, to: @new_user, title: "foo", body: "foo")
end
end
@@ -118,11 +117,11 @@ class DmailTest < ActiveSupport::TestCase
context "sending a dmail" do
should "fail if the user has sent too many dmails recently" do
10.times do
Dmail.create_split(from: @user, to: create(:user), title: "blah", body: "blah", creator_ip_addr: "127.0.0.1")
Dmail.create_split(from: @user, to: create(:user), title: "blah", body: "blah")
end
assert_no_difference("Dmail.count") do
@dmail = Dmail.create_split(from: @user, to: create(:user), title: "blah", body: "blah", creator_ip_addr: "127.0.0.1")
@dmail = Dmail.create_split(from: @user, to: create(:user), title: "blah", body: "blah")
assert_equal(false, @dmail.valid?)
assert_equal(["You can't send dmails to more than 10 users per hour"], @dmail.errors[:base])
@@ -133,7 +132,7 @@ class DmailTest < ActiveSupport::TestCase
context "destroying a dmail" do
setup do
@recipient = create(:user)
@dmail = Dmail.create_split(from: @user, to: @recipient, creator_ip_addr: "127.0.0.1", title: "foo", body: "foo")
@dmail = Dmail.create_split(from: @user, to: @recipient, title: "foo", body: "foo")
@modreport = create(:moderation_report, model: @dmail)
end

View File

@@ -5,12 +5,10 @@ class NoteTest < ActiveSupport::TestCase
setup do
@user = FactoryBot.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "#merge_version" do
@@ -77,7 +75,6 @@ class NoteTest < ActiveSupport::TestCase
assert_equal(1, @note.version)
assert_equal(1, @note.versions.first.version)
assert_equal(@user.id, @note.versions.first.updater_id)
assert_equal(CurrentUser.ip_addr, @note.versions.first.updater_ip_addr.to_s)
end
should "update the post's last_noted_at field" do
@@ -120,7 +117,6 @@ class NoteTest < ActiveSupport::TestCase
assert_equal("fafafa", @note.versions.last.body)
assert_equal(2, @note.version)
assert_equal(@user.id, @note.versions.last.updater_id)
assert_equal(CurrentUser.ip_addr, @note.versions.last.updater_ip_addr.to_s)
end
context "without making any changes" do