better validation for bulk update requests
This commit is contained in:
@@ -4,10 +4,12 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
context "creation" do
|
||||
setup do
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "create a forum topic" do
|
||||
@@ -16,6 +18,20 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "that has an invalid alias" do
|
||||
setup do
|
||||
@alias1 = FactoryGirl.create(:tag_alias)
|
||||
@req = FactoryGirl.build(:bulk_update_request, :script => "create alias bbb -> aaa")
|
||||
end
|
||||
|
||||
should "not validate" do
|
||||
assert_difference("TagAlias.count", 0) do
|
||||
@req.save
|
||||
end
|
||||
assert_equal(["Error: A tag alias for aaa already exists (create alias bbb -> aaa)"], @req.errors.full_messages)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an associated forum topic" do
|
||||
setup do
|
||||
@admin = FactoryGirl.create(:admin_user)
|
||||
|
||||
@@ -60,7 +60,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
ta2 = FactoryGirl.build(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
ta2.save
|
||||
assert(ta2.errors.any?, "Tag alias should be invalid")
|
||||
assert_equal("Tag alias can not create a transitive relation with another tag alias", ta2.errors.full_messages.join)
|
||||
assert_equal("A tag alias for bbb already exists", ta2.errors.full_messages.join)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user