]> projects.mako.cc - selectricity/blobdiff - app/models/selectricity_service.rb
* Add one more assertion in testcase for dupe candidates
[selectricity] / app / models / selectricity_service.rb
index 4075f6401fa40f889f16be53ac80fc7b17398d57..9e276ef502e89b0a41acde7c7f9ef25412cb3342 100644 (file)
@@ -21,6 +21,8 @@ class SelectricityService < ActionWebService::Base
       voter.save!
       voter.vote.confirm!
       voter.save!
+    else
+      raise ArgumentError.new "Cannot find election #{election_name}"
     end
   end
   def quickvote_candidate_ids_to_names(shortname, id_list)
@@ -78,7 +80,7 @@ class SelectricityService < ActionWebService::Base
       return result
     end
     qv.votes.each  do |vote|
-      votes << VoteInfo.new(:voter_id => vote.voter.id, :voter_ipaddress => vote.voter.ipaddress, :vote_time => vote.time.to_i)
+      votes << VoteInfo.new(:voter_id => vote.voter.id, :voter_ipaddress => vote.voter.ipaddress, :vote_time => vote.time.to_i, :vote => vote.votes)
     end
     return votes
   end
@@ -96,7 +98,11 @@ class SelectricityService < ActionWebService::Base
   def create_quickvote(election)
     qv=QuickVote.new(:name => election.name, :description => election.description)
     qv.candidatelist=election.candidate_names
-    return qv.save.to_s
+    if qv.save
+      return ""
+    else
+      return "Saving quickvote FAILED:"+qv.errors.inspect
+    end
   end
 
 end

Benjamin Mako Hill || Want to submit a patch?