aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-08 18:20:05 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-10 18:21:04 +0200
commitcdabbcd4c068bf4591998b33a769187683eef17f (patch)
tree368426c4fb38096331d35626943d93a576f11fc6
parentReceive list of meeting participants from IRC bot (diff)
downloadcouncil-webapp-cdabbcd4c068bf4591998b33a769187683eef17f.tar.gz
council-webapp-cdabbcd4c068bf4591998b33a769187683eef17f.tar.bz2
council-webapp-cdabbcd4c068bf4591998b33a769187683eef17f.zip
Handle proxies attendance
Mark council member who appointed proxy as present, not proxy.
-rw-r--r--site/app/models/participation.rb3
-rw-r--r--site/spec/models/participation_spec.rb12
2 files changed, 12 insertions, 3 deletions
diff --git a/site/app/models/participation.rb b/site/app/models/participation.rb
index b7ca39a..e76ebf5 100644
--- a/site/app/models/participation.rb
+++ b/site/app/models/participation.rb
@@ -37,6 +37,9 @@ class Participation < ActiveRecord::Base
agenda = Agenda.current
for nick in participant_nicks
user = ::User.find_by_irc_nick(nick)
+ unless user.council_member?
+ user = Proxy.proxy_is(user).agenda_is(agenda)._?.first.council_member
+ end
next if user.nil?
Participation.create! :irc_nick => user.irc_nick,
:participant => user,
diff --git a/site/spec/models/participation_spec.rb b/site/spec/models/participation_spec.rb
index 242abde..395dc03 100644
--- a/site/spec/models/participation_spec.rb
+++ b/site/spec/models/participation_spec.rb
@@ -25,15 +25,21 @@ describe Participation do
a = Factory(:agenda)
Factory(:agenda, :state => 'old')
+ Factory(:proxy, :proxy => u.first,
+ :council_member => non_participants.last,
+ :agenda => a)
+
results_hash = {
'Whatever' => { u[0].irc_nick => 'Yes', u[1].irc_nick => 'Yes', u[2].irc_nick => 'Yes'},
'Something else' => { u[0].irc_nick => 'Yes', u[1].irc_nick => 'No'}
}
+ present = u - [u.first] + [non_participants.last]
Participation.mark_participations(results_hash)
- (Participation.all.*.irc_nick - u.*.irc_nick).should be_empty
- (u.*.irc_nick - Participation.all.*.irc_nick).should be_empty
- (u - Participation.all.*.participant).should be_empty
+ (Participation.all.*.irc_nick - present.*.irc_nick).should be_empty
+ (present.*.irc_nick - Participation.all.*.irc_nick).should be_empty
+ (present - Participation.all.*.participant).should be_empty
+ (Participation.all.*.participant - present).should be_empty
end
end
end