Set approver of aliases/implications in BURs.

Previously only the BUR's approver was set when a BUR was approved. Set
the approver for each alias/implication in the BUR as well.

Additionally:

* Refactor `approve!` to take a user instead of just a user id.
* Be mass-assignment permissions aware when setting approver_id.
This commit is contained in:
evazion
2016-10-26 18:40:58 -05:00
parent 1e8a68a56b
commit 6dd8ec909d
8 changed files with 29 additions and 35 deletions

View File

@@ -22,7 +22,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
)
@bur = FactoryGirl.create(:bulk_update_request, :script => @script)
@bur.approve!(@admin.id)
@bur.approve!(@admin)
@ta = TagAlias.where(:antecedent_name => "foo", :consequent_name => "bar").first
@ti = TagImplication.where(:antecedent_name => "bar", :consequent_name => "baz").first
@@ -72,7 +72,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
should "handle errors gracefully" do
@req.stubs(:update_forum_topic_for_approve).raises(RuntimeError.new("blah"))
assert_difference("Dmail.count", 1) do
@req.approve!(@admin.id)
@req.approve!(@admin)
end
assert_match(/Exception: RuntimeError/, Dmail.last.body)
assert_match(/Message: blah/, Dmail.last.body)
@@ -84,7 +84,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
should "update the topic when processed" do
assert_difference("ForumPost.count") do
@req.approve!(@admin.id)
@req.approve!(@admin)
end
end