diff --git a/app/logical/bulk_revert.rb b/app/logical/bulk_revert.rb
index b5929ab2c..446231487 100644
--- a/app/logical/bulk_revert.rb
+++ b/app/logical/bulk_revert.rb
@@ -4,12 +4,10 @@ class BulkRevert
class ConstraintTooGeneralError < Exception ; end
- def self.process(constraints)
- obj = BulkRevert.new(constraints)
-
+ def process
ModAction.log("#{CurrentUser.name} processed bulk revert for #{constraints.inspect}")
- obj.find_post_versions.order("updated_at, id").each do |version|
+ find_post_versions.order("updated_at, id").each do |version|
version.undo!
end
end
diff --git a/app/views/moderator/bulk_reverts/new.html.erb b/app/views/moderator/bulk_reverts/new.html.erb
index a968b6b6c..2d87e13d0 100644
--- a/app/views/moderator/bulk_reverts/new.html.erb
+++ b/app/views/moderator/bulk_reverts/new.html.erb
@@ -23,11 +23,13 @@
<%= submit_tag "Test" %>
@@ -78,18 +80,18 @@
<% content_for(:html_header) do %>
<%= javascript_tag do %>
$(function() {
- if ($("#constraints_user_name").val().length === 0) {
- $("#added-tags-input").hide();
- $("#removed-tags-input").hide();
+ if (!$("#constraints_user_name").val().length) {
+ $("#added-tags-input input").prop("disabled", true);
+ $("#removed-tags-input input").prop("disabled", true);
}
$("#constraints_user_name").keyup(function() {
- if ($("#constraints_user_name").val().length > 0) {
- $("#added-tags-input").show();
- $("#removed-tags-input").show();
+ if ($("#constraints_user_name").val().length) {
+ $("#added-tags-input input").prop("disabled", false);
+ $("#removed-tags-input input").prop("disabled", false);
} else {
- $("#added-tags-input").hide();
- $("#removed-tags-input").hide();
+ $("#added-tags-input input").prop("disabled", true);
+ $("#removed-tags-input input").prop("disabled", true);
}
});
});
diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb
index 4bf2dd6e4..0aee3d891 100644
--- a/app/views/static/site_map.html.erb
+++ b/app/views/static/site_map.html.erb
@@ -120,6 +120,7 @@
<% if CurrentUser.is_moderator? %>
<%= link_to("IP Bans", ip_bans_path) %>
+ <%= link_to("Bulk Revert", new_moderator_bulk_revert_path) %>
<% end %>
<% if CurrentUser.is_admin? %>
diff --git a/test/unit/bulk_revert_test.rb b/test/unit/bulk_revert_test.rb
new file mode 100644
index 000000000..a3ab57eb0
--- /dev/null
+++ b/test/unit/bulk_revert_test.rb
@@ -0,0 +1,18 @@
+require 'test_helper'
+
+class BulkRevertTest < ActiveSupport::TestCase
+ context "#find_post_versions" do
+ subject do
+ BulkRevert.new(added_tags: "hoge")
+ end
+
+ setup do
+ subject.expects(:query_gbq).returns([1,2,3])
+ end
+
+ should "revert all changes found in a search" do
+ q = subject.find_post_versions
+ assert_match(/post_versions\.id in \(1,2,3\)/, q.to_sql)
+ end
+ end
+end