aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-12 19:30:22 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-14 13:15:31 +0200
commit0fec02c76ad5a30f11da522cfff9cd8f3ef09eef (patch)
tree26b748c45416a9249e015115bcc8546c49e1d0cb /app/models
parentImprove Answer model tests coverage (diff)
downloadrecruiting-webapp-0fec02c76ad5a30f11da522cfff9cd8f3ef09eef.tar.gz
recruiting-webapp-0fec02c76ad5a30f11da522cfff9cd8f3ef09eef.tar.bz2
recruiting-webapp-0fec02c76ad5a30f11da522cfff9cd8f3ef09eef.zip
Improve coverage of User model and fix found bugs
Found bugs: - User#any_pending_project_acceptances? was returning true even if all acceptances were already accepted - User#answered_all_multi_choice_questions? didn't work with grouped multiple choice questions Side note : scopes in Question need cleaning (eg. unanswered should just select unanswered questions (not unanswered and grouped like it does now))
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index cb6afbe..4982a13 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -133,7 +133,7 @@ class User < ActiveRecord::Base
end
def any_pending_project_acceptances?
- (ProjectAcceptance.count :conditions => { :accepting_nick => nick }) > 0
+ (ProjectAcceptance.count :conditions => { :accepting_nick => nick, :accepted => false}) > 0
end
# This returns named scope, so it's efficient to use
@@ -148,7 +148,7 @@ class User < ActiveRecord::Base
def answered_all_multi_choice_questions?
Question.multiple_choice.ungrouped_questions_of_user(id).unanswered(id).count == 0 &&
- Question.multiple_choice.grouped_questions_of_user(id).unanswered(id).count == 0
+ Question.multiple_choice.grouped_questions_of_user(id).unanswered_grouped(id).count == 0
end
def required_questions_count
@@ -195,6 +195,8 @@ class User < ActiveRecord::Base
end
def changes_allowed_for_recruiter?
+ return mentor_picked_up_or_resigned? if mentor_changed?
+
# make sure recruiters change only what they are allowed to
return false unless only_changed?(:question_categories, :role, :nick)