diff options
-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 |