aboutsummaryrefslogtreecommitdiff
path: root/poll.rb
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 20:20:45 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-11-24 20:20:45 +0100
commit4279e3023c4f437cd4fb996e0535fe09241823cf (patch)
treea3fcdd2e7380a13894e427d8571eb975b225edc3 /poll.rb
parent8b7e89a4c09638c2f02416aa5644ab83d6a84237 (diff)
quick n dirty fix for sorting problem. Have to rethink data model
Diffstat (limited to 'poll.rb')
-rw-r--r--poll.rb38
1 files changed, 23 insertions, 15 deletions
diff --git a/poll.rb b/poll.rb
index 39367d1..7f315d8 100644
--- a/poll.rb
+++ b/poll.rb
@@ -379,30 +379,38 @@ end
class PollTest < Test::Unit::TestCase
Y,N,M = Poll::YESVAL, Poll::NOVAL, Poll::MAYBEVAL
A,B,C,D = "Alice", "Bob", "Carol", "Dave"
- Q,W,E,R = "2009-05-05 ", "2009-05-23 10:00 ", "2009-05-23 11:00 ", "2009-05-23 foo "
+ Q,W,E,R = "2009-05-05", "2009-05-23 10:00", "2009-05-23 11:00", "2009-05-23 foo"
def setup
- def add_participant(user,votearray)
+ def add_participant(type,user,votearray)
h = { Q => votearray[0], W => votearray[1], E => votearray[2], R => votearray[3]}
- @poll.add_participant("",user,h)
+ @polls[type].add_participant("",user,h)
end
- @poll = Poll.new(SITE, "time")
+ @polls = {}
+ ["time","normal"].each{|type|
+ @polls[type] = Poll.new(SITE, type)
- @poll.edit_column("","2009-05-05", {})
- 2.times{|t|
- @poll.edit_column("","2009-05-23", {"columntime" => "#{t+10}:00"})
- }
- @poll.edit_column("","2009-05-23", {"columntime" => "foo"})
+ @polls[type].edit_column("","2009-05-05", {"columndescription" => ""})
+ 2.times{|t|
+ @polls[type].edit_column("","2009-05-23 #{t+10}:00", {"columntime" => "#{t+10}:00","columndescription" => ""})
+ }
+ @polls[type].edit_column("","2009-05-23", {"columntime" => "foo","columndescription" => ""})
- add_participant(A,[Y,N,Y,N])
- add_participant(B,[Y,Y,N,M])
- add_participant(D,[N,M,Y,Y])
- add_participant(C,[Y,Y,M,N])
+ add_participant(type,A,[Y,N,Y,N])
+ add_participant(type,B,[Y,Y,N,M])
+ add_participant(type,D,[N,M,Y,Y])
+ add_participant(type,C,[Y,Y,M,N])
+ }
end
def test_sort
- assert_equal([A,B,C,D],@poll.sort_data("name").collect{|a| a[0]})
- assert_equal([B,C,D,A],@poll.sort_data(W).collect{|a| a[0]})
+ ["normal","time"].each{|type|
+ comment = "Test Type: #{type}"
+ assert_equal([A,B,C,D],@polls[type].sort_data("name").collect{|a| a[0]},comment)
+ assert_equal([A,B,D,C],@polls[type].sort_data("timestamp").collect{|a| a[0]},comment)
+ assert_equal([B,C,D,A],@polls[type].sort_data([W,"name"]).collect{|a| a[0]},comment)
+ assert_equal([B,A,C,D],@polls[type].sort_data([Q,R,E]).collect{|a| a[0]},comment)
+ }
end
end