diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-24 15:00:40 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-24 18:50:06 +0200 |
commit | 13bef04afeacceb530aa159cfb5ada789b7f4380 (patch) | |
tree | fb0807cd4b0b76023fa850eb2f2582da52dbd6ed /site/spec | |
parent | Add support for #timelimit (add|list|remove) commands (diff) | |
download | council-webapp-13bef04afeacceb530aa159cfb5ada789b7f4380.tar.gz council-webapp-13bef04afeacceb530aa159cfb5ada789b7f4380.tar.bz2 council-webapp-13bef04afeacceb530aa159cfb5ada789b7f4380.zip |
Send timelimits to bot
Diffstat (limited to 'site/spec')
-rw-r--r-- | site/spec/models/agenda_item_spec.rb | 19 | ||||
-rw-r--r-- | site/spec/models/agenda_spec.rb | 17 |
2 files changed, 28 insertions, 8 deletions
diff --git a/site/spec/models/agenda_item_spec.rb b/site/spec/models/agenda_item_spec.rb index 3df2a59..72ee0bb 100644 --- a/site/spec/models/agenda_item_spec.rb +++ b/site/spec/models/agenda_item_spec.rb @@ -100,4 +100,23 @@ describe AgendaItem do a.should_not be_editable_by(u, :agenda) end end + + it 'should make sure timelimits are valid' do + valid_timelimits = ["", "0:0", "1:1 message", "1:2 longer message", + "30:40 a few messages\n5:60 as separate lines"] + invalid_timelimits = ["a:0", "1:", "2:a", ":0", " 1:1 message", + "30:40 a few messages\n\n5:60 and an empty line", + "30:40 a few messages\n5:60 and an wrong line\na:"] + + valid_timelimits.each do |limit| + Factory(:agenda_item, :timelimits => limit).should be_valid + end + + invalid_timelimits.each do |limit| + item = AgendaItem.new :title => 'title', :timelimits => limit + item.should_not be_valid + item.errors.length.should be_equal(1) + item.errors[:timelimits].should_not be_nil + end + end end diff --git a/site/spec/models/agenda_spec.rb b/site/spec/models/agenda_spec.rb index b9fbd36..34db02f 100644 --- a/site/spec/models/agenda_spec.rb +++ b/site/spec/models/agenda_spec.rb @@ -126,9 +126,9 @@ describe Agenda do Vote.count.should be_equal(9) - u[0].votes.*.voting_option.*.description.should == ['Yes', 'Yes', 'Dunno'] - u[1].votes.*.voting_option.*.description.should == ['Yes', 'No', 'Dunno'] - u[2].votes.*.voting_option.*.description.should == ['Yes', 'Dunno', 'No'] + u[0].votes.*.voting_option.*.description.sort.should == ['Dunno', 'Yes', 'Yes'] + u[1].votes.*.voting_option.*.description.sort.should == ['Dunno', 'No', 'Yes'] + u[2].votes.*.voting_option.*.description.sort.should == ['Dunno', 'No', 'Yes'] a1.voting_options.*.votes.flatten.*.voting_option.*.description.should == ['Yes', 'Yes', 'Yes'] a2.voting_options.*.votes.flatten.*.voting_option.*.description.should == ['Yes', 'No', 'Dunno'] a3.voting_options.*.votes.flatten.*.voting_option.*.description.should == ['No', 'Dunno', 'Dunno'] @@ -236,15 +236,16 @@ describe Agenda do it 'should return proper voting_array' do old_agenda = Factory(:agenda, :state => 'old') current_agenda = Factory(:agenda) - i1 = Factory(:agenda_item, :agenda => old_agenda) - i2 = Factory(:agenda_item, :agenda => current_agenda) - i3 = Factory(:agenda_item, :agenda => current_agenda) + i1 = Factory(:agenda_item, :agenda => old_agenda, :timelimits => '0:0') + i2 = Factory(:agenda_item, :agenda => current_agenda, :timelimits => "10:0 Ten minutes passed") + i3 = Factory(:agenda_item, :agenda => current_agenda, :timelimits => "0:10 Ten seconds passed") v11 = Factory(:voting_option, :agenda_item => i1) v21 = Factory(:voting_option, :agenda_item => i2) v22 = Factory(:voting_option, :agenda_item => i2, :description => 'other') - old_agenda.voting_array.should == [[i1.title, [v11.description]]] - current_agenda.voting_array.should == [[i2.title, [v21.description, v22.description]], [i3.title, []]] + old_agenda.voting_array.should == [[i1.title, [v11.description], i1.timelimits]] + current_agenda.voting_array.should == [[i2.title, [v21.description, v22.description], + i2.timelimits], [i3.title, [], i3.timelimits]] end end |