fix tests
This commit is contained in:
@@ -28,7 +28,7 @@ class BulkUpdateRequestsController < ApplicationController
|
||||
end
|
||||
|
||||
def approve
|
||||
@bulk_update_request.approve!
|
||||
@bulk_update_request.approve!(CurrentUse.user.id)
|
||||
flash[:notice] = "Bulk update request approved"
|
||||
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
|
||||
end
|
||||
|
||||
@@ -33,9 +33,12 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
|
||||
extend SearchMethods
|
||||
|
||||
def approve!
|
||||
def approve!(approver_id)
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1", true).process!
|
||||
update_columns(:status => "approved", :approver_id => CurrentUser.user.id)
|
||||
self.status = "approved"
|
||||
self.approver_id = approver_id
|
||||
self.skip_secondary_validations = true
|
||||
save
|
||||
update_forum_topic_for_approve
|
||||
|
||||
rescue Exception => x
|
||||
|
||||
@@ -13,7 +13,7 @@ class SuperVoterTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "create super voter objects" do
|
||||
assert_difference("SuperVoter.count") do
|
||||
assert_difference("SuperVoter.count", 2) do
|
||||
SuperVoter.init!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,9 +42,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
|
||||
CurrentUser.scoped(@admin, "127.0.0.1") do
|
||||
@req.approve!
|
||||
end
|
||||
@req.approve!(@admin.id)
|
||||
end
|
||||
assert_match(/Exception: RuntimeError/, Dmail.last.body)
|
||||
assert_match(/Message: blah/, Dmail.last.body)
|
||||
@@ -56,9 +54,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
|
||||
should "update the topic when processed" do
|
||||
assert_difference("ForumPost.count") do
|
||||
CurrentUser.scoped(@admin, "127.0.0.1") do
|
||||
@req.approve!
|
||||
end
|
||||
@req.approve!(@admin.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -155,15 +155,15 @@ class DTextTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_inline_tags
|
||||
assert_equal('<p><a href="/posts?tags=tag">tag</a></p>', p("{{tag}}"))
|
||||
assert_equal('<p><a rel="nofollow" href="/posts?tags=tag">tag</a></p>', p("{{tag}}"))
|
||||
end
|
||||
|
||||
def test_inline_tags_conjunction
|
||||
assert_equal('<p><a href="/posts?tags=tag1+tag2">tag1 tag2</a></p>', p("{{tag1 tag2}}"))
|
||||
assert_equal('<p><a rel="nofollow" href="/posts?tags=tag1+tag2">tag1 tag2</a></p>', p("{{tag1 tag2}}"))
|
||||
end
|
||||
|
||||
def test_inline_tags_special_entities
|
||||
assert_equal('<p><a href="/posts?tags=%3C3"><3</a></p>', p("{{<3}}"))
|
||||
assert_equal('<p><a rel="nofollow" href="/posts?tags=%3C3"><3</a></p>', p("{{<3}}"))
|
||||
end
|
||||
|
||||
def test_extra_newlines
|
||||
|
||||
@@ -191,28 +191,24 @@ class PostTest < ActiveSupport::TestCase
|
||||
context "a parent" do
|
||||
should "not reassign favorites to the parent by default" do
|
||||
p1 = FactoryGirl.create(:post)
|
||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id, :score => 1)
|
||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
||||
user = FactoryGirl.create(:gold_user)
|
||||
c1.add_favorite!(user)
|
||||
c1.delete!
|
||||
p1.reload
|
||||
assert(Favorite.exists?(:post_id => c1.id, :user_id => user.id))
|
||||
assert(!Favorite.exists?(:post_id => p1.id, :user_id => user.id))
|
||||
assert_equal(2, c1.score)
|
||||
assert_equal(0, p1.score)
|
||||
end
|
||||
|
||||
should "reassign favorites to the parent if specified" do
|
||||
p1 = FactoryGirl.create(:post)
|
||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id, :score => 1)
|
||||
c1 = FactoryGirl.create(:post, :parent_id => p1.id)
|
||||
user = FactoryGirl.create(:gold_user)
|
||||
c1.add_favorite!(user)
|
||||
c1.delete!(:move_favorites => true)
|
||||
p1.reload
|
||||
assert(!Favorite.exists?(:post_id => c1.id, :user_id => user.id), "Child should not still have favorites")
|
||||
assert(Favorite.exists?(:post_id => p1.id, :user_id => user.id), "Parent should have favorites")
|
||||
assert_equal(1, c1.score)
|
||||
assert_equal(1, p1.score)
|
||||
end
|
||||
|
||||
should "not update the parent's has_children flag" do
|
||||
|
||||
Reference in New Issue
Block a user