aboutsummaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-28 17:53:04 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-07-05 11:58:11 +0200
commit38bfc2754eeb6db9697a1f258fc652875566e8ba (patch)
tree96a52e05501106bf901bd2f13fef35947d2b32b7 /site
parentAgenda.current creates new agenda if needed (diff)
downloadcouncil-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.tar.gz
council-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.tar.bz2
council-webapp-38bfc2754eeb6db9697a1f258fc652875566e8ba.zip
Show slacking status properly when there were no meetings yet.
Diffstat (limited to 'site')
-rw-r--r--site/app/models/user.rb3
-rw-r--r--site/spec/models/user_spec.rb6
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