notes: drop unused undo_changes_by_user method.

This commit is contained in:
evazion
2020-02-16 23:10:24 -06:00
parent 2dab9aa075
commit 7723597675
2 changed files with 0 additions and 40 deletions

View File

@@ -137,20 +137,6 @@ class Note < ApplicationRecord
new_note.save
end
def self.undo_changes_by_user(vandal_id)
transaction do
note_ids = NoteVersion.where(:updater_id => vandal_id).select("note_id").distinct.map(&:note_id)
NoteVersion.where(["updater_id = ?", vandal_id]).delete_all
note_ids.each do |note_id|
note = Note.find(note_id)
most_recent = note.versions.last
if most_recent
note.revert_to!(most_recent)
end
end
end
end
def self.available_includes
[:post]
end

View File

@@ -163,32 +163,6 @@ class NoteTest < ActiveSupport::TestCase
end
end
context "when notes have been vandalized by one user" do
setup do
@vandal = FactoryBot.create(:user)
@note = FactoryBot.create(:note, :x => 5, :y => 5)
CurrentUser.scoped(@vandal, "127.0.0.1") do
@note.update(x: 10, y: 10)
end
end
context "the act of undoing all changes by that user" do
should "revert any affected notes" do
assert_equal(2, NoteVersion.count)
assert_equal([1, 2], @note.versions.map(&:version))
assert_equal([@user.id, @vandal.id], @note.versions.map(&:updater_id))
travel(1.day) do
Note.undo_changes_by_user(@vandal.id)
end
@note.reload
assert_equal([1, 3], @note.versions.map(&:version))
assert_equal([@user.id, @user.id], @note.versions.map(&:updater_id))
assert_equal(5, @note.x)
assert_equal(5, @note.y)
end
end
end
context "searching for a note" do
setup do
@note = FactoryBot.create(:note, :body => "aaa")