aboutsummaryrefslogtreecommitdiff
path: root/site/spec
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-08 19:02:32 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-10 18:30:37 +0200
commit53201e0add36dd0ca796fa349108bc533890eedb (patch)
tree1284107c1b987b0fcd45ea70738b15f81df7710f /site/spec
parentHandle proxies attendance (diff)
downloadcouncil-webapp-53201e0add36dd0ca796fa349108bc533890eedb.tar.gz
council-webapp-53201e0add36dd0ca796fa349108bc533890eedb.tar.bz2
council-webapp-53201e0add36dd0ca796fa349108bc533890eedb.zip
Show slacking information in the application
Using participations
Diffstat (limited to 'site/spec')
-rw-r--r--site/spec/models/user_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/site/spec/models/user_spec.rb b/site/spec/models/user_spec.rb
index bdffa30..2dd5bde 100644
--- a/site/spec/models/user_spec.rb
+++ b/site/spec/models/user_spec.rb
@@ -14,4 +14,72 @@ describe User do
u.should_not be_guest
u.should be_signed_up
end
+
+ describe '.slacking_status_in_period' do
+ it 'should give "Was on last meeting" slacking status to user who was on all meetings' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a)
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'Was on last meeting'
+ end
+
+ it 'should give "Was on last meeting" slacking status to user who was on last meeting and skipped some meetings in past (but not two consecutive)' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a) if i.even?
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'Was on last meeting'
+ end
+
+ it 'should give "Skipped last meeting" slacking status to user who was absent on last meeting and skipped some meetings in past (but not two consecutive)' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a) if i.odd?
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'Skipped last meeting'
+ end
+
+ it 'should give "Slacker" slacking status to user who was present on last meeting skipped two consecutive meeting in the past' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a) unless [1, 3, 5, 6].include?(i)
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'Slacker'
+ end
+
+ it 'should give "No more a council" slacking status to user who skipped two consecutive meeting in the past and the last one' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a) unless [1, 3, 5, 6, 10].include?(i)
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'No more a council'
+ end
+
+ it 'should give "No more a council" slacking status to user who skipped two consecutive meeting in the past and then one more' do
+ u = users_factory(:council)
+ agendas = (1..10).collect do |i|
+ a = Factory(:agenda, :state => 'old')
+ Factory(:participation, :participant => u, :agenda => a) unless [5, 6, 8].include?(i)
+ a
+ end
+ u.slacking_status_in_period(agendas.first.meeting_time - 1.minute,
+ agendas.last.meeting_time + 1.minute).should == 'No more a council'
+ end
+ end
end