From 23c5d764866ae11c5a65cd872647ce026544decb Mon Sep 17 00:00:00 2001 From: John Dong Date: Fri, 17 Aug 2007 16:15:45 -0400 Subject: [PATCH] * Add one more assertion in testcase for dupe candidates * Remove test_create_quickvote_description_htmlescape. As I thought earlier, I actually want the DB to properly store HTML elements. It's the job of the view to make sure it doesn't clobber itself displaying the element. - Change the test instead to a test for proper XML escaping. An appended element should be stored properly and not trip hell --- test/unit/selectricityservice_test.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/unit/selectricityservice_test.rb b/test/unit/selectricityservice_test.rb index 6014c72..446520b 100644 --- a/test/unit/selectricityservice_test.rb +++ b/test/unit/selectricityservice_test.rb @@ -98,17 +98,24 @@ class SelectricityServiceTest < Test::Unit::TestCase def test_create_quickvote_dupe_candidates election = ElectionStruct.new :name => "foobar", :description => "valid", :candidate_names => ["Apple", "Apple", "Apple", "Apple"] assert_create_quickvote_fails election + + # Previous may pass coincidentally if a uniq! then a sizecheck reveals too few unique names + # We don't want this to happen. Dupe canidates should fail regardless of how many are left. + + election = ElectionStruct.new :name => "foobar", :description => "valid", :candidate_names => ["Apple", "Apple", "Orange", "Orange", "Pineapple" , "Pineapple"] + assert_create_quickvote_fails election end def test_create_quickvote_candidates_nil_mixed election = ElectionStruct.new :name => "foobar", :description => "valid", :candidate_names => ["Apple", nil ] assert_create_quickvote_fails election end - def test_create_quickvote_description_htmlescape - election = ElectionStruct.new :name => "foobar", :description => "test", :candidate_names => ["Apple", "Orange", "Banana", "Pineapple"] + def test_create_quickvote_description_xmlescape + # Will an embedded XML element bork the table? + election = ElectionStruct.new :name => "foobar", :description => "test ", :candidate_names => ["Apple", "Orange", "Banana", "Pineapple"] result = invoke_delegated :vote, :create_quickvote, election assert_equal result, "" reflection = invoke_delegated :vote, :get_quickvote, election.name - assert_not_equal election.description, reflection.description + assert_equal election.description, reflection.description assert_not_equal reflection.description.length, 0 end private -- 2.39.5