diff options
author | 2011-06-28 17:53:04 +0200 | |
---|---|---|
committer | 2011-07-05 11:58:11 +0200 | |
commit | 38bfc2754eeb6db9697a1f258fc652875566e8ba (patch) | |
tree | 96a52e05501106bf901bd2f13fef35947d2b32b7 | |
parent | Agenda.current creates new agenda if needed (diff) | |
download | council-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.tar.gz council-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.tar.bz2 council-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.zip |
Show slacking status properly when there were no meetings yet.
-rw-r--r-- | site/app/models/user.rb | 3 | ||||
-rw-r--r-- | site/spec/models/user_spec.rb | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/site/app/models/user.rb b/site/app/models/user.rb index 7809e87..cde0df5 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -58,6 +58,9 @@ class User < ActiveRecord::Base num_status = 0 agendas = Agenda.all :conditions => ['agendas.meeting_time BETWEEN ? AND ?', start_date, end_date], :order => :meeting_time + + return 'There were no meetings in this term yet' if agendas.count.zero? + for agenda in agendas if Participation.participant_is(self).agenda_is(agenda).count == 0 num_status += 1 if num_status < 3 diff --git a/site/spec/models/user_spec.rb b/site/spec/models/user_spec.rb index 5246015..ad36761 100644 --- a/site/spec/models/user_spec.rb +++ b/site/spec/models/user_spec.rb @@ -81,6 +81,12 @@ describe User do 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 return "There were no meetings in this term yet" if there were no meeting yet' do + a = Factory(:agenda, :meeting_time => 1.year.from_now) + u = users_factory(:council) + u.slacking_status_in_period(1.year.ago, 1.month.from_now).should == "There were no meetings in this term yet" + end end it 'should allow no one to create' do |