Fix #3965: Extraneous API attributes.

Remove the updater_id/updater_ip_addr virtual attributes from
pools/notes. Juss pass them in as params to create_version instead.
This commit is contained in:
evazion
2018-10-30 14:32:55 -05:00
parent 39374a70d3
commit f5012464ab
8 changed files with 25 additions and 26 deletions

View File

@@ -7,6 +7,5 @@ FactoryBot.define do
height 1
is_active true
body {FFaker::Lorem.sentences.join(" ")}
updater_ip_addr "127.0.0.1"
end
end

View File

@@ -85,6 +85,8 @@ class NoteTest < ActiveSupport::TestCase
assert_equal(@note.body, @note.versions.first.body)
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
@@ -141,6 +143,8 @@ class NoteTest < ActiveSupport::TestCase
assert_equal(2, @note.versions.last.version)
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 "for a note-locked post" do

View File

@@ -252,6 +252,8 @@ class PoolTest < ActiveSupport::TestCase
@pool.reload
assert_equal(2, @pool.versions.size)
assert_equal(user2.id, @pool.versions.last.updater_id)
assert_equal("127.0.0.2", @pool.versions.last.updater_ip_addr.to_s)
CurrentUser.scoped(user2, "127.0.0.3") do
@pool.post_ids = "#{@p1.id} #{@p2.id}"
@@ -260,6 +262,8 @@ class PoolTest < ActiveSupport::TestCase
@pool.reload
assert_equal(3, @pool.versions.size)
assert_equal(user2.id, @pool.versions.last.updater_id)
assert_equal("127.0.0.3", @pool.versions.last.updater_ip_addr.to_s)
end
should "should create a version if the name changes" do

View File

@@ -35,6 +35,7 @@ class UserTest < ActiveSupport::TestCase
end
assert(@user.dmails.exists?(from: bot, to: @user, title: "You have been promoted"))
refute(@user.dmails.exists?(from: bot, to: @user, title: "Your user record has been updated"))
end
end